Repository navigation
Resolve a temporal foreign key's generic principal from a migration snapshot (#197) - #199
Merged
CaffeinatedCoder merged 2 commits intoOct 23, 2026
Merged
Conversation
…ion snapshot A temporal foreign key stores its principal as the CLR FullName, which for a generic type is "Room`1[[System.Int32, ...]]" where EF names the entity type "Room<int>". The live model matched through ClrType; a snapshot's property-bag type has no CLR type, so the principal did not resolve and every diff from the snapshot threw: each migrations add after the first, has-pending-model-changes, and Migrate()'s pending-changes check. EntityTypeNames.FromClrFullName converts the stored name by EF Core's own display rule (keywords for built-in types, T? for Nullable<T>, nested generic segments, array ranks), and ResolveEntityType matches either form. Stored names are unchanged, since snapshots hold them. Closes #197 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…c-temporal-principal # Conflicts: # CHANGELOG.md # src/EFCore.ComplexIndexes.PostgreSQL/CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #197
Into
release/5.x. Found by the focused 5.6.0 sweep (round-trip lens). It has been present since temporal foreign keys shipped; it isn't a 5.6.0 regression.Closesacts only onmain, so #197 is closed by hand after the merge.Problem
A temporal foreign key whose principal is a generic entity type (
Room<int>) couldn't be diffed from its migration snapshot. The declaration stores the principal astypeof(TPrincipal).FullName, which is…Room`1[[System.Int32, …]], while EF names the entity type…Room<int>. The live model matched throughClrType.FullName. A snapshot's property-bag type hasClrType == Dictionary<string, object>, soResolveEntityTypefound nothing and threw. The firstmigrations addpassed. Every later one,has-pending-model-changes, andMigrate()'s pending-changes check failed, even with no change. It also hid the snapshot path of #187/#188's tests, which use generic types.Change
EntityTypeNames.FromClrFullName(new, internal, PostgreSQL package) converts a CLRFullNameto EF Core's entity-type name, followingSharedTypeExtensions.DisplayName(fullName: true)in EF Core 10: keywords for built-in types,T?forNullable<T>, each segment of a nested generic type with its own arguments, and array ranks as written. Input it can't read comes back unchanged.ResolveEntityTypematches the stored name, its EF form, or the CLRFullName.FullNameform, and writing another would rewrite them.Also: a
### Fixedline in the root and PostgreSQL changelogs, and CLAUDE.md.Tests
SnapshotRoundTripTests.Temporal_foreign_key_to_a_generic_principal_roundtrip_is_noop: a temporal FK toRoundTripGenericRoom<int>, diffed from its Roslyn-compiled snapshot against the unchanged model, yields no operations.EntityTypeNameTests: EF's own model is the oracle. For 11 shapes the conversion oftype.FullNameequals the nameModelBuilder.Entity(type)gives: non-generic,Generic<int>,<string>,<Guid>,<int?>,<int[]>,<List<long>>,<Generic<bool>>,Pair<int, string>,Pair<DateOnly?, Plain>, andOuter<int>.Inner.ResolveEntityTypechange reverted: the snapshot test fails with "Could not resolve temporal foreign key principal entity …Room`1[[System.Int32…".🤖 Generated with Claude Code