Search code examples
.netentity-frameworkinheritanceentity-framework-4.1table-per-type

Entity Framework 4.1 updates to TPT and TPCT models?


I last tried out the Entity Framework when it was at version 4.0. My experiments with it, confirmed by some posts on the MSDN forums and elsewhere, indicated that the TPT (table-per-type) and TPCT (table-per-concrete-type) models for database to OOP mapping was very poorly supported, and indeed incomplete. Worst of all, the SQL generated for TPT/TPCT queries was complete spaghetti and highly inefficient, to the extent that for any realistic type hierarchy, it was unusable.

My question is, has any of this change in the EF 4.1 update? Specifically:

  • Is there now proper designer support for the TPT and TPCT approaches?

  • Is the SQL generated for TPT/TPCT queries/updates now reasonably efficient?

  • Any other information on the subject of these models.


Solution

  • The answer is no. EF 4.1 consists of two features:

    • DbContext API
    • Code first support

    Code first support doesn't use designer at all - mapping is done completely in the code and it reflect functionality provided by designer. DbContext API is a new fancy way to work with EF. It is somehow simplified so the usage is better but in the same time some functionality from original ObjectContext API is missing.

    What will interests you the most is the fact that DbContext API is just wrapper around ObjectContext API. Nothing more. There are absolutely no changes in core EF functionality because main System.Data.Entity.dll assembly has not changed. You still need this assembly when working with EF 4.1 + you need new EntityFramework.dll assembly with mentioned new features. That means:

    • Designer is still the same. The only new feature is DbContext Generator T4 template
    • Generated SQL is exactly the same