所以我有以下 EF 模型:
[Table("Site")]
public class Store{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int ID { get; set; }
[ForeignKey("ID")]
public virtual ICollection<Item> Items { get; set; }
}
[Table("Item")]
public class Item {
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int ID { get; set; }
[Column("SiteID")]
public int storeID { get; set; }
[ForeignKey("storeID")]
public Store store { get; set; }
}
因此,从 Item->Store 开始似乎很好,数据填充。但是 Store->Items 没有填充。我究竟做错了什么?