Here we are on EF Core and got 3 tables:
And also (except news, items): content, message, form, etc.
And my model definitions
public class Item { public int Id { get; set; } public string Name { get; set; } public decimal Price { get; set; } public Link Link { get; set; } } public class News { public int Id { get; set; } public string Header { get; set; } public string Content { get; set; } public Link Link { get; set; } } public class Link { public int Id { get; set; } public string Type { get; set; } public int RowId { get; set; } public string Url { get; set; } }
The Links table describes the URL for each news item and each item. This means that Links has 4 columns:
- Id
- Type - News or Product
- RowId - contains the identifier of the product or news (depending on type)
- URL
How to set up a relationship? Keep in mind that we need to enable Entity at the URL in the link table.
c # asp.net-core .net-core entity-framework-core ef-code-first-mapping
Alex
source share