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.
As a simplified example:
Vehicle
----------------
VehicleId
Make
Model
----------------
Car
----------------
CarId
SomeOtherField
----------------
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?
Here is a statement about this issue from the EF team:
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.
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?