我有来自AdventureWorks2008数据库的以下关系表。
BusinessEntity(表) BusinessEntityId Int(PK,Identity) 人(表) BusinessEntityId int(PK,带有BusinessEntity表的参考) FullName varchar(255)
此处Person表没有自动生成的Id,而是引用BusinessEntity表。
如果我使用Fluent NHibernate上面的映射将是 Id(x => x.BusinessEntityId) .GeneratedBy.Foreign(" BusinessEntity");
如何在codefirst CTP 4中映射它? AdventureWorks2008是一个复杂的关系设计,如果来自EF团队的人可以使用CodeFirst映射该数据库,那么这将是最好的例子。
谢谢
Ashraf。
解决方案
如果我没有弄错,在这个模型中,Person是一个BusinessEntity(因此BusinessEntityID是PK)。我会将其建模为继承的实体关系人:的BusinessEntity
I have the following relational table from the AdventureWorks2008 database.
BusinessEntity (Table) BusinessEntityId Int (PK, Identity) Person (Table) BusinessEntityId int (PK, Reference with BusinessEntity table) FullName varchar(255)
Here Person table do not have auto generated Id, instead it reference to BusinessEntity table.
If I use Fluent NHibernate the mapping for the above would be Id(x => x.BusinessEntityId) .GeneratedBy.Foreign("BusinessEntity");
How do I map it in codefirst CTP 4? AdventureWorks2008 is a complex relational design, if someone from EF team can map that database using CodeFirst, then that would be the best example.
Thanks
Ashraf.
解决方案If I'm not mistaken, in this model Person IS A BusinessEntity (hence the BusinessEntityID being the PK). I would model it as an inherited entity relationship Person:BusinessEntity.
更多推荐
CodeFirst一对一关系问题
发布评论