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.


tptIllustration

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.


tpcIllustration

 

http://huagati.blogspot.com/2010/10/mixing-inheritance-strategies-in-entity.html

Comments (3) -

sumeyye
21.11.2014 13:41:28 #

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

Erkan Yurek
22.4.2015 23:24:00 #

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

Erkan Yurek
22.4.2015 23:26:50 #

Bu linkden erkanyurek.com/.../Code-First-TPH-tipler-Table-per-Hierarchy 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.