2010-08-23 18 views
0

我想創建一個使用外鍵/導航屬性作爲鑑別器的TPH繼承層次結構,並且遇到了一些麻煩。在實體框架中使用導航屬性作爲鑑別器在TPH繼承場景4

我有以下實體:

Person: 
    Id (int) 
    Name (nvarchar) 
    PlaneId (int) 
    CarId (int) 

Car: 
    Id (int) 
    Name (nvarchar) 

Plane: 
    Id (int) 
    Name (nvarchar) 

PlaneIdCarId beign FKS。我在數據庫中有相應的表格,我可以使用VS2010 EF嚮導創建一個概念模型。然後Person實體具有兩個導航屬性CarPlane

現在我想從人得到兩種類型:

Pilot (condition: PlaneId is not null) 
Driver (condition: CarId is not null) 

所以,我想補充的實體試驗,告訴它映射到人,並添加條件PlaneId is not null。在這一點上,Visual Studio(或edmgen我猜)抱怨屬性Person.PlaneId with 'IsNull=false' condition must be mapped

我的下一步是什麼?我嘗試了各種方法,但似乎無法使其發揮作用。任何有識之士將不勝感激。

回答