开发者

Complex Inheritance in Entity Framework

That's my first post here. Thanks in advance everyone that collaborates with me.

I'm working on a new MER, this is a pi开发者_开发百科ece of the it: http://i.stack.imgur.com/jt5Mz.png.

Complex Inheritance in Entity Framework

In the linked MER, i'm using Table per Hierarchy on entities: Person, Company and Individual. Driver entity is on based on Table per Type.

My big problem is that a Driver can be Individual or Company.

Both Individual or Company inherites from Person that holds common fields from both entities.

There is a way to make the Driver entity flexible to be an Individual or a Company, using the Table per Type on Driver entity?

Thanks you all!!!


I think you need to change it so that Driver HAS A Person instead of Driver IS A Person. i.e. you have a separate Driver class and it has a field on it called Person and that 'Person' is either an individual or a company.

OR you should move the DriverNumber field to the Person class so that a Person (Individual or Company) can be a 'Driver' if they happen to have a driver number.


Why not change the design to say that a 'Driver' is 'associated' (0..1) rather than inherited from a Person. Basically making 'driver' an optional entity of person then both individual or company will inherit this.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜