Code First TPH, TPH, TPC

Mixing inheritance strategies in Entity Framework models 

The Microsoft Entity Framework v4 runtime supports three entity inheritance models: TPT, TPH, and TPC. When using the built-in EF designer and tools in Microsoft Visual Studio 2010, the default inheritance strategy in model-first scenarios is TPT. TPH inheritance can be manually mapped in the designer, and TPC requires editing the mapping (MSL) in the EDMX file manually or using third party tools.

TPT, TPH, and TPC explained

TPT is short for Table Per Type. In TPT inheritance, there is one central table containing all the base class members and then one table per subclass containing the key and the members that are immediate (non-inherited) members of the subclass. In database terms this can be described as a normalized model, with additional tables for members that are not always present.


TPH is short for Table Per Hierarchy. In TPH inheritance there is only one table representing the base class and all subclasses. Members must be nullable to avoid errors when a subclass don't contain members of another subclass. In database terms TPH can be described as a denormalized model, since one wide table is used to represent all of the types in the hierarchy with columns that are left with a null value if they are not members of the entity type.tphIllustration

TPC is short for Table Per Concrete type. In TPC inheritance, every class in a inheritance hierarchy will have their own table.

The inheritance hierarchy masks the fact that there are several independent underlying tables, representing each subtype.


Comments (3) -

11/21/2014 1:41:28 PM #

kopyalamadan önce bari türkçeye çevireydin. bi anlamı olurdu

Erkan Yurek
4/22/2015 11:24:00 PM #

Turkceye cevirecek zamanim olmadi, uzgunum. Malesef yazilimin dili ingilizcedir. Bir yazilimci ingilizce bilmelidir diye dusunuyorum.

Erkan Yurek
4/22/2015 11:26:50 PM #

Bu linkden turkce bizzan kendi calismam bulunmakta.

Add comment

The file '/Custom/Widgets/Calendar/widget.cshtml' does not exist.The file '/Custom/Widgets/Category list/widget.cshtml' does not exist.The file '/Custom/Widgets/Tag cloud/widget.cshtml' does not exist.The file '/Custom/Widgets/Page List/widget.cshtml' does not exist.The file '/Custom/Widgets/Month List/widget.cshtml' does not exist.