Wednesday, February 13, 2013

Table Per Type(TPH) Inheritance in Entity Framework, a Beginner's guide oneness (well understanding at least)...

CodeProject - A Beginner's Tutorial on Understanding Table Per Type(TPH) Inheritance in Entity Framework


In this article we will discuss about implementing Table per Type inheritance hierarchy using Entity Framework. We will see a small sample to see how this can be implemented in a step by step manner.


There are times when our database design has tables that do not logically match with the entities that we need in our application. There could be chances that the database has too many or too few tables than the entities required logically by the application. Some other times when the tables are created one per logical entity but the relationship between them is not logical from the application and entity perspective.

Inheritance in entity framework provides a way to create the required logical entities to act on a set of database tables and also to create a more meaningful relationship between entities using inheritance.

There are three type of inheritance relationships in the entity framework. Table per type(TPT), Table per hierarchy (TPH) and Table per concrete type(TPC).

In this article we will try to look at the Table per Type inheritance relationship because from an efficiency standpoint this tends to be the efficient(comparatively) and this provides a great way to model the tables having one to one relationships.



Since I'm an EF newbe, I can use all the Idiots Beginner's guides I can get... :)

No comments: