Repository navigation
Description
Found by a pre-release sweep of release/5.x @ e563ba1 (lens: round-trip); reproduced in a scratch SnapshotRoundTripTests case, and again by the caller. Present since the temporal foreign key shipped; not a 5.6.0 regression.
Problem
A temporal foreign key whose principal is a generic entity type (Room<int>) cannot be diffed from its snapshot. The declaration stores the principal as typeof(TPrincipal).FullName (NpgsqlTemporalConstraintExtensions.cs:110), the CLR form …+Room`1[[System.Int32, System.Private.CoreLib, Version=10.0.0.0, …]]. ResolveEntityType (NpgsqlComplexIndexMigrationsModelDiffer.cs:1706) matches it against e.Name (EF's display name, …+Room<int>) or e.ClrType.FullName. The live model matches through ClrType; a snapshot's property-bag type has ClrType == Dictionary<string, object>, so nothing matches and BuildForeignKeyDescriptors throws.
The first migrations add passes, because there is no snapshot yet. Every later migrations add, has-pending-model-changes, and Migrate()'s pending-changes check throw, even with no change:
System.InvalidOperationException: Could not resolve temporal foreign key principal entity 'EFCore.ComplexIndexes.Tests.SnapshotRoundTripTests+GRoom`1[[System.Int32, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' from dependent entity '…+GBooking<int>'.
at NpgsqlComplexIndexMigrationsModelDiffer.BuildForeignKeyDescriptors(...)
It also hid the snapshot path of #187/#188's tests, which use Room<TKey>/Booking<TKey>.
Change
Resolve the stored name in either form: also match an entity type whose EF name equals the stored CLR name with its generic arguments rendered as EF names them (`1[[T, asm]] → <T>). Stored names cannot change, since snapshots hold the FullName form. Optionally store Metadata.Name for new declarations and keep the FullName match for old snapshots. The stored form also carries Version=10.0.0.0, which a runtime major upgrade would change.
Test
SnapshotRoundTripTests: a temporal FK to Room<int>, diffed from its compiled snapshot against the unchanged model, yields no operations. Plus TemporalForeignKeyOrderingTests' scenarios from a snapshot source.
Activity
Merge pull request #199 from CaffeinatedCoder/fix/197-generic-tempora…
CaffeinatedCoder commentedon Oct 23, 2026
Fixed on release/5.x by #199, shipping in 5.6.0. Closed by hand:
Closesacts only on merges intomain.ResolveEntityTypenow also matches the stored CLRFullNameconverted to EF Core's entity-type name (EntityTypeNames.FromClrFullName, EF Core's own display rule), so a temporal foreign key to a generic principal such asRoom<int>diffs from its snapshot. Stored names are unchanged.