问题描述
我正在尝试在遗留数据库上映射TPT继承层次结构(我不能更改列名称)。所有示例都具有相同名称的父表和子表的主键。不幸的是,我的行为不这样。
I am trying to map a TPT inheritance hierarchy on a legacy database (I can't change column names). All of the examples have the primary keys of the parent and children tables with the same name. Unfortunately, mine doesn't behave this way.
作为一个简化的例子:
Vehicle
----------------
VehicleId
Make
Model
----------------
Car
----------------
CarId
SomeOtherField
----------------
CarId和VehicleId实际上是相同的id,并且是用于关联表的值。有没有支持在Code First中创建一个TPT关系?
CarId and VehicleId are actually the same id and are the values that should be used to associate the tables. Is there any support for creating this as a TPT relationship in Code First?
推荐答案
是EF团队关于这个问题的声明:
Here is a statement about this issue from the EF team:
它是从2011年2月开始的。因此,它与早期的C Code版本的EF Code-First有关。但是我相信EF 4.1中仍然不支持这种情况。
It's from February 2011. So it was related to an earlier CTP version of EF Code-First. But I believe that this scenario is still not supported in EF 4.1.
另外一个类似的问题在这里不符合EF 4.1 Code-First的结果:
Also a similar question here with not satisfying result regarding EF 4.1 Code-First: How can I use TPT inheritance models when primary keys have different names?
这篇关于映射TPT在EF代码首先4.1 w /不同的主键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!