Last post Apr 22, 2015 06:20 AM by vahid bakkhi
Apr 22, 2015 01:35 AM|Naveen Bommidi|LINK
which is the best Inheritance with the Entity Framework Code First approach in foolowing?
• The Table per Type (TPT) inheritance
• The Table per Class Hierarchy (TPH) inheritance
• The Table per Concrete Class (TPC) inheritance
Apr 22, 2015 02:10 AM|Mikesdotnetting|LINK
You should read this very good series of articles to understand what each of those strategies are and how you should choose the most appropriate one:
Apr 22, 2015 02:19 AM|vahid bakkhi|LINK
If you have many different sub classes you can have a lot of extra joins in queries involving those more complex types which can hurt performance. One big advantage of TPH is that you query one table for all types in the hierarchy and this is a boon for
performance, particularly for larger hierarchies. For this reason i tend to favour that approach in most scenarioes
However, TPH means that you can no longer have
However i would tend to use TPT if there were a lot of fields for each type and that the number of types in the hierarchy was likely to be small, meaning that performance was not so much of an issue with the joins, and you get better data integrity.
Note that one of the advantages of EF and other ORMs is that you can change your mind down the track without impacting your application so the decision doesn't need to be completely carved in stone.
In your example, it doesn't appear to have an inheritance relationship, it looks like a one to many from the address type to the addresses
Apr 22, 2015 02:41 AM|Naveen Bommidi|LINK
What about TPC?
Apr 22, 2015 06:20 AM|vahid bakkhi|LINK