Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Entity Framework Inheritance Types

DZone's Guide to

Entity Framework Inheritance Types

· ·
Free Resource

In Sela SDP Entity Framework Inheritance Types
conference I was
asked if Entity
Framework
supports
inheritance mapping.
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.
Topics:

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}