开发者

Entity framework 4.0 and inheritance

I want to have an abstract class Employee, and 2 derived classes; Staff and Operative. In my DB design, I have开发者_运维技巧 an Employee table and an EmployeeType table. The Employee table contains 2 rows, one with Staff lookup data and the other with Operative lookup data. Using EF4, how do I transform this DB structure into a class design specifies above?


I think I understand what you are asking...so assuming you have three table: Employee, Staff, and Operative. You want Employee to be an abstract class that is the base for Staff and Operative. In the database you have FKs in the Employee table to the Staff and Operative tables.

In EF just create the entities from all three tables. In the properties of the Employee entity, set Abstract = true. In the Staff and Operative entities set Base Type = Employee. That should setup the inheritance you are looking to achieve.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜