我在codeplex http://entityframework.codeplex.com/workitem/2087上发布了我的问题 .
这里也有一些问题,但没有成功回答 .
看到
Mapping TPT in EF Code First 4.1 w/ Different Primary Keys
How can I use TPT inheritance models when primary keys have different names?
Is it now possible to have different column names for the primary keys when using TPT? May be with 6.1.0
2 回答
在TPT中,你're essentially do not want to declare the key in the subclasses, you'否则会错过这一点 .
如果必须具有不同的Id名称,只需在子类中将代理属性映射到基本Id .
考虑将子字段标记为NotMapped,以防您不应将它们包含在LINQ查询中 .
看看这段代码片段 . 它的工作正确我:
现在,我们必须为数据库表重命名继承的ID(使用流畅的API):