CTP5中同一桌上的两个一对多 [英] Two One to Many on the same table in CTP5
本文介绍了CTP5中同一桌上的两个一对多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Based on the sample you have shared with us before, can you please tell me how to set this up to work, i am interested in the Primary and Secondary Category entries. Nothing seems to work when i
add the Secondary. It feels like i need to use the Fluent API
Thanks
public class Category
{
public string CategoryCode { get; set; }
public string Name { get; set; }
public virtual ICollection<Product> Products { get; set; }
}
public class Product
{
public int ProductId { get; set; }
public string Name { get; set; }
public string PrimaryCategoryCode { get; set; }
public virtual Category PrimaryCategory { get; set; }
public string SecondaryCategoryCode { get; set; }
public virtual Category SecondaryCategory { get; set; }
public virtual ICollection<Tag> Tags { get; set; }
}
推荐答案
尝试:
public string PrimaryCategoryCode { get; set; }
[ForeignKey("PrimaryCategoryCode")]
public virtual Category PrimaryCategory { get; set; }
public string SecondaryCategoryCode { get; set; }
[ForeignKey("SecondaryCategoryCode")]
public virtual Category SecondaryCategory { get; set; }
- Sharad
--Sharad
这篇关于CTP5中同一桌上的两个一对多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文