Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The process of mapping an entity and its derived class using EF Core TPC is as follows:

  1. Define the base entity class and the derived class with their respective properties.

  2. Apply the Table-Per-Concrete-Type (TPC) pattern by creating a separate table for each class and keeping all the properties in the parent table.

  3. In the parent/entity class, use the HasKey method to specify the primary key.

  4. Include the Discriminator property in the base/entity class and set its value using the HasDiscriminator property.

  5. Configure each derived class using the HasBaseType method and specify its discriminator value using the HasValue method.

  6. Use the OnModelCreating method to specify the mapping between the entity and its derived classes using the Fluent API.

  7. Ensure that the foreign key relationships between the parent/entity class and the derived classes are correctly specified.

  8. Test the mapping to ensure that the inheritance hierarchy is correctly handled by the EF Core TPC implementation.