Also see part-2 of this blog post- Entity Framework code first and Inheritance–Table per hierarchyRecently I am using Entity Framework a lot. So I tried some of advance scenario and this post related to it only. In this post we will learn how entity framework handles inheritance.
In object oriented world, We all use Inheritance for reusability. We create some base classes and inherit those in child classes to facilitate code reuse and we don’t have to write again and again. In this post we will also have same kind of methodology. We are going to create a “Person” class and inherit this in to Employee and Customer class and we are going to see how entity framework code first handles this kind of inheritance by default. I’m going to use entity framework version 6.0 and Visual Studio 2013.
So what we are waiting for. Let’s get started. So create a console application from file menu new project.
Once you are done with creating a application. It’s time to add entity framework via nuget package.