Hi,
I am trying to create a TPH inheritance hierarchy using foreign keys / navigation properties as discriminators and I am having some trouble getting it right.
I have the following entities:
Person:
Id (int)
Name (nvarchar)
PlaneId (int)
CarId (int)
Car:
Id (int)
Name (nvarchar)
Plane:
Id (int)
Name (nvarchar)
with PlaneId
and CarId
beign FKs. I have corresponding tables in a database and I can create a conceptual model using the VS2010 EF wizard. The Person
entity then has two navigation properties, Car
and Plane
.
Now I want to derive two types from Person:
Pilot (condition: PlaneId is not null)
Driver (condition: CarId is not null)
So, I add the entity Pilot, tell it to map to Person and add the condition PlaneId is not null
. At this point Visual Studio (or edmgen I guess) complains that the property Person.PlaneId with 'IsNull=false' condition must be mapped
.
What is my next step? I have tried various approaches, but can't seem to get it to work. Any insight would be greatly appreciated.