SolarX
SolarX

Reputation: 1943

Entity Framework: mix table per type and table per hierarchy

I have two tables in my database:

The "Fund" entity inherits from "BaseEtity" with "table per type".

In my business model I have different types of "Fund":

I would like to have different entities for those types with "table per hierarchy", meaning that I still only have one "Fund" table with a type-discriminator column.

Is there a way to have "table per hierarchy" on an entity that derives from a base class with "table per type"?

Upvotes: 7

Views: 2121

Answers (2)

Danny Varod
Danny Varod

Reputation: 18069

Yes, it is possible - I have had this working in EF4 for some time now.

Define EntityA and map to TableA

Define EntityB: EntityA and map to TableB

Define EntityC: EntityA and map to TableC

Define EntityD: EntityC and map to TableC
    with condition on a column from table C

Define EntityE: EntityC and map to TableC
    with a different condition on a column from table C

Upvotes: 4

ShahidAzim
ShahidAzim

Reputation: 1494

It is not possible, see this post for reference:

Can I mix Table per Hierarchy and Table per Type in Entity Framework?

Upvotes: -1

Related Questions