Entity Framework Inheritance Types
In Sela SDP
conference I was
asked if Entity
The answer I gave
was a small 25 minutes improvised session which I gave after
the EF4 session I had. In the following three posts I’m going to
explain the main three inheritance ways that you can use with EF.
These ways are supported in other ORMs as well.
Why to Use Inheritance?
One of the ORMs main purposes is to enable us the domain developers
to create a conceptual model that resemble our way of thinking about
our domain. Since we use Object Oriented principals like inheritance to
express the domain there is a need to create the inheritances in
the data storages that we use. But how can we create the inheritance
graph in a database and map it within the ORM?
The Main Inheritance Ways
There are three main ways (or combinations of these ways):
- Table Per Type inheritance (TPT).
- Table Per Hierarchy inheritance (TPH).
- Table Per Concrete Type inheritance (TPC).
As I wrote, I’ll explain every one of these ways and show EF examples
in a follow up series.