I'm using EntityFramework Core, Code First and Fluent Api to define model database, and i've follow situation about strategy of map inheritance:
public class Person
{
public int Id { get; set; }
public string Name { get; set; }
}
public class User : Person
{
public string UserName { get; set; }
public string Password { get; set; }
}
public class Employee : Person
{
public decimal Salary { get; set; }
}
public class Customer:Person
{
public long DiscountPoints { get; set; }
}
Business logical
In this case, users, employees and customers are people, however employees and customers are also users, as well as an employees can become a customer. And each type is used in distinct appication contexts.
I implemented this way to not use values from other application contexts unnecessarily.
Questions:
-
What are the best practice to map a database model? Type-Per-Hyerarchy or Table-Per-Type? a. If TPH, how to use discriminator field to many types? b. If TPT, how to use this strategy in the EF Core 1.0?
-
Is it the best architecture for the business model?
thank you for your attention and collaboration
Aucun commentaire:
Enregistrer un commentaire