In Entity Framework, how is Table-per-Type (TPT) inheritance different from Table-per-Hierarchy (TPH)?

  • All types in the hierarchy are mapped to a single table.
  • Each type in the inheritance hierarchy has its own table.
  • The base type and its derived types are stored in separate files.
  • The base type and its derived types share the same table.
Table-per-Type (TPT) inheritance in Entity Framework maps each type in the inheritance hierarchy to its own table in the database. This means the base type and its derived types have separate tables, and the tables are connected through a shared primary key. Unlike TPH, TPT ensures that each type has its own table, which can lead to a more normalized database schema. However, it may result in complex queries due to the need for joins to retrieve data from multiple tables.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *