Implementing inheritance – Table per Class hierarchy

The relational and the object-oriented world, although similar, are in fact quite different. In the object-oriented world, we have classes and inheritance, references to other classes, virtual and static members, and different visibilities, which all make our life as developers easier. Relational databases are very simple: all we have are tables (and views) and foreign keys. So, an object-relational mapper such as Entity Framework faces a difficult task translating from one to the other where there is no 1:1 correspondence of concepts: this is called the object-relational impedance mismatch.

In this topic, we will focus on inheritance. Tables do not have inheritance, but there are some patterns ...

Get Entity Framework Core Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.