Support for temporal tables for TPT (Table per Type) and other entity-splitting scenarios

Open
#26,457 19 comments 86 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp
Domain
databases

Research direction

Start with SqlServerModelValidator.ValidateTemporalTables and the t => t.IsTemporal() configuration described in the issue. Reproduce the migration failure for TPT and entity-splitting mappings, then trace the temporal-table validation and migration behavior. Done means temporal tables work with these mappings without the current InvalidOperationException and are covered by appropriate tests.

Written by the indexing model from the issue text.

Description

area-model-building area-query area-temporal-tables customer-reported

Temporal tables for TPT tables

We are developing an application that currently use the concept of Table-Per-Type to minimize the duplication of fields instead of using a discriminator that is required with Table-Per-Hierarchy. More tables are planned in the future that will depend on the same parent table.

With the latest version of EF Core, we saw an opportunity to use the new temporal table support to easily keep track of operations in our tables. After adding t => t.IsTemporal() build action to our tables configuration and try to add a new migration, we received the following error:

Temporal tables are only supported for entities using Table-Per-Hierarchy inheritance mapping.

This message is returned through an InvalidOperationException in SqlServerModelValidator.ValidateTemporalTables when EF detect a derived table mapping in one of the tables for which we're trying to configure the temporal build action.

We were not able to find much information related to this restriction of temporal for TPT as per those are quite new features supported in EF Core 5 for TPT and EF Core 6 for temporal tables.

Is support planned in the future for both mechanisms to work on the same set of tables?

Thanks!

Version information

EF Core version: (6.0.0-rc.2.21480.5)
Database provider: (Microsoft.EntityFrameworkCore.SqlServer)
Target framework: (.NET 6.0.0-rc.2.21480.5)
IDE: (e.g. Visual Studio 2022 17.0.0 Preview 6)

Dominant language
C#
Stars
14.8k
Forks
3.4k
Avg merge
2d 5h
Merged PRs (30d)
134

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/efcore

All issues in dotnet/efcore

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.