- How to choose an Inheritance Strategy
- Inheritance with EF Code First: Part 1 – Table per Hierarchy (TPH)
There are 3 different approaches to implementing inheritance with Entity Framework.
|Table Per Hierarchy (TPH)||All data for a given hierarchy in one table.|
|Table Per Type (TPT)||Each type has it’s own table. The base class has the shared attributes.|
|Table Per Concrete Class (TPC)||Each type has it’s own table. The database doesn’t share fields across entities.|
Each approach has it’s advantages.
Table Per Hierarchy (TPH)
Table Per Hierarchy is generally better performing, because no joins are necessary, everything is in one table.
Table Per Type (TPT)
Most commonly used. Allows for a more flexible design.
Table Per Concrete Class (TPC)
Has some issues with working within the VS EDMX IDE.