I use MS SQL Server and Entity Framework Core , it’s impossible to set the tables in the database correctly.
I have an Item table - this is a product. Table Order - order. Order can have many Item . Item should not store Order information. To store information about the goods in the order there is a separate table ItemOrder .
Item
public class Item { public int Id { get; set; } public string Name { get; set; } public double Price { get; set; } } Order
public class Order { public int Id { get; set; } public int UserId { get; set; } public List<Item> Items { get; set; } } ItemOrder
public class ItemOrder { public int ItemId { get; set; } public Item Item { get; set; } public int OrderId { get; set; } public Order Order { get; set; } } At the moment, when creating a database, the OrderId field is added to the Item table, and I need the goods in the order to be ItemOrder in the ItemOrder table. How can I specify this in the Entity Framework Core code?
