This approach will generate one table on the database to represent all the inheritance structure.
Example:
public abstract class Person
{
public int Id { get; set; }
public string Name { get; set; }
public DateTime BirthDate { get; set; }
}
public class Employee : Person
{
public DateTime AdmissionDate { get; set; }
public string JobDescription { get; set; }
}
public class Customer : Person
{
public DateTime LastPurchaseDate { get; set; }
public int TotalVisits { get; set; }
}
// On DbContext
public DbSet<Person> People { get; set; }
public DbSet<Employee> Employees { get; set; }
public DbSet<Customer> Customers { get; set; }
The table generated will be:
Table: People Fields: Id Name BirthDate Discrimitator AdmissionDate JobDescription LastPurchaseDate TotalVisits
Where 'Discriminator' will hold the name of the subclass on the inheritance and 'AdmissionDate', 'JobDescription', 'LastPurchaseDate', 'TotalVisits' are nullable.
Advantages
Disadvantages