You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Omit unsupported collations from complex-collection snapshots - #39481
A global string UseCollation() convention causes snapshots to emit unsupported calls on JSON-mapped complex-collection properties, making the generated C# uncompilable.
Snapshot generation: Filter collation annotations from complex-collection properties before generating fluent API calls. Preserve collations on ordinary properties.
Regression coverage: Cover the global convention and nested complex collections, including compilation of generated snapshots.
CopilotAI
changed the title
[WIP] Fix global UseCollation() convention for ComplexCollection properties
Omit unsupported collations from complex-collection snapshots
Oct 30, 2026
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
A moderate-severity finding remains: the snapshot collation filter also drops collations on primitive collections inside complex collections, even though those builders support collation and only regular properties should be filtered.
This PR fixes a bug where a global UseCollation() convention made the generated model snapshot contain calls that do not compile on JSON-mapped complex collections. The snapshot generator now drops collation for complex-collection properties. Regular properties keep their collation. The PR adds a regression test that builds the generated snapshot and checks the collations that are kept and dropped.
Changes:
The snapshot generator removes the collation annotation for properties declared in a complex collection.
A new test covers the global convention on a complex collection and checks that the generated snapshot compiles and keeps collations on ordinary properties.
An existing test now sets and checks a collation on a complex-collection property, so the omission is covered there too.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The new collation filter in the snapshot generator also drops collations from primitive collections inside complex collections, which support them, so those collations would be silently lost from the snapshot and no test covers that path.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Add snapshot test for collated primitive collections
The new test only covers a regular string property, so it misses the primitive-collection path changed in src/EFCore.Design/Migrations/Design/CSharpSnapshotGenerator.cs:482-485. Primitive collections inside a complex collection support UseCollation, so the new filter can drop their collation from snapshots and no test fails. Add a test that sets a collation on a primitive collection inside a complex collection and asserts it survives the snapshot round-trip.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated.
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
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.
A global string
UseCollation()convention causes snapshots to emit unsupported calls on JSON-mapped complex-collection properties, making the generated C# uncompilable.