Loading ...

Inheritance Strategy In Code First

Hello everybody,

today I want to write about reflecting hierarchy of classes in db with help of code-first.

There are three types: 

  1. Table per Hierarchy
  2. Table per Type
  3. Table per conreate class.

Below goes more detailed description

 

  • Table per Hierarchy (TPH): one table for the entire class inheritance hierarchy. Table includes discriminator column which distinguishes between inheritance classes. This is a default inheritance mapping strategy in Entity Framework.
  • Table per Type (TPT): This approach suggests a separate table for each domain class.
  • Table per Concrete class (TPC): one table for one concrete class, but not for the abstract class. So, if you inherit the abstract class in multiple concrete classes, then the properties of the abstract class will be part of each table of the concrete class.

Ready to take your Acumatica development to the next level? Whether you're working with Table per Hierarchy, Table per Type, or Table per Concrete class, customizing your database structure to fit your unique business needs is key. If you have a specific customization request or need expert guidance on implementing these strategies, we’re here to help! Leave us a request today, and let’s build a solution that perfectly aligns with your goals. Your ideal Acumatica setup is just a message away!