.NET Data Community Standup - TPH, TPT, and TPC Inheritance mapping with EF Core

Ғылым және технология

Type inheritance hierarchies as used in object-oriented programming do not map naturally to relational database schemas. In this live stream, we will look at different strategies for inheritance mapping when using EF Core with a relational database. This includes table-per-hierarchy (TPH) mapping, table-per-type (TPT) mapping, and table-per-concrete type (TPC) mapping, which is new in EF Core 7.0 preview 5. We will look at the consequences of the mapping on the generated SQL and consider the performance and storage implications. This will result in some guidance as to when each strategy should be used.
Community Links: www.theurlist.com/dotnet-data...
Featuring: Arthur Vickers (@ajcvickers)
Get your questions answered on the Microsoft Q&A for .NET - aka.ms/dotnetqa

Learn .NET with free self-guided learning from Microsoft Learn: aka.ms/learndotnet
#entityframework #efcore #orm

Пікірлер: 10

  • @jaymesingleton-xamarincomm8998
    @jaymesingleton-xamarincomm89982 жыл бұрын

    Best intro ever!!!!

  • @PanosKao
    @PanosKao Жыл бұрын

    00:56:53 TPC tables can use unique sequence ID by using the following. .Property(e => e.Id).HasDefaultValueSql("NEXT VALUE FOR [AnimalIds]"); 01:08:00 TPH tables can use IsSparse() to reduce the space of null data, but Perf. may be sacrified. 01:24:12 TPH tables may use Discriminator as Enum to improve the perf. 01:26:34 TPC tables can use UseHiLo() with SQL. SQL-Lite does not support UseHiLo(). 01:30:13 The reason to use "await context.AddRangeAsync()" is UseHiLo(). 01:33:00 HiLo confuses a lot of people because of the keys-gap . 01:35:00 Arthur recommended not using HiLo for simplicity. 01:37:25 If you update one raw at a time, you don't need HiLo.

  • @allanbum
    @allanbum2 жыл бұрын

    Thanks from Brazil! 👋👋👋

  • @koala59230
    @koala59230 Жыл бұрын

    thanks you for this great standup.

  • @mohamed-hassan-
    @mohamed-hassan-4 ай бұрын

    Amazing Info, Thanks a lot

  • @malkythealky
    @malkythealky3 ай бұрын

    Is it still necessary to define a sequence for the Id field when using TPC stratgey in EF Core 8? Thanks!

  • @johanredander6360
    @johanredander636011 ай бұрын

    Where can I find an working example doing this ? Like a small project ?

  • @alexisfibonacci
    @alexisfibonacci2 жыл бұрын

    A varchar discriminator column hurts performance. Either use char(1) or a numeric value.

  • @mhDuke
    @mhDuke4 ай бұрын

    I still do not understand how Human.FavoriteAnimal navigation will get the right Animal type, you guys just touched the point that there is no foreign key constraint between Human and Animal which is a natural limitation that comes with TBC, but how does ef handle the navigation?! are we going to left join all child tables?

  • @zhant69
    @zhant698 ай бұрын

    TPC is at 52''

Келесі