dotnet / dotnet/efcore

EF Core 6.0 temporal tables - Support specifying HISTORY_RETENTION_PERIOD

Open
#27,224 6 comments 68 reactions 0 assignees View on GitHub
area-model-building area-temporal-tables customer-reported
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

**What problem are you trying to solve?**

Right now there is no way to specify HISTORY_RETENTION_PERIOD when defining a temporal table. Also, EF Core doesn't create create a clustered index for PeriodEnd and PeriodStart columns in history table which is a prerequisite to use HISTORY_RETENTION_PERIOD.

**Describe the solution you'd like**
```
builder.ToTable(tableBuilder => tableBuilder.IsTemporal(temporalTableBuilder =>
{
temporalTableBuilder.HasPeriodStart("MyPeriodStart");
temporalTableBuilder.HasPeriodEnd("MyPeriodEnd");
temporalTableBuilder.UseHistoryTable("MyHistory");
temporalTableBuilder.UseHistoryRetentionPeriod("12 MONTHS"); // <--- something like this
}));
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.