-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[release/10.0] Fix snapshot generation for complex collection properties #37271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release/10.0
Are you sure you want to change the base?
Conversation
|
@copilot Add a ModelDiffer test to check that no operations are generated when the model contains an annotation that's ignored in the snapshot |
Skip generating HasMaxLength and HasPrecision annotations for properties in complex collections since ComplexCollectionTypePropertyBuilder doesn't support these methods. Also skip IsConcurrencyToken and ValueGenerated* methods for the same reason. Fixes #37256 Co-authored-by: AndriySvyryd <[email protected]>
Add test to verify that no operations are generated when the model contains annotations (like MaxLength) that are ignored in the snapshot for complex collection properties. Addresses review feedback from @AndriySvyryd Co-authored-by: AndriySvyryd <[email protected]>
Added |
test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.ModelSnapshot.cs
Outdated
Show resolved
Hide resolved
test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTest.cs
Show resolved
Hide resolved
- Remove method overloads with isInComplexCollection parameter - Check property.DeclaringType directly to determine if in complex collection - Update test to also configure IsConcurrencyToken, ValueGenerated, precision and scale - Empty target lambda in ModelDiffer test as snapshot doesn't have extra config Addresses review feedback from @AndriySvyryd Co-authored-by: AndriySvyryd <[email protected]>
|
@copilot Update progress by rewriting the PR summary using this template: |
... Updated the PR description with the requested template format. |
Fixes #37256
Description
Snapshot generation for properties in complex collections produces uncompilable code because it emits fluent API calls (
HasMaxLength,HasPrecision,IsConcurrencyToken,ValueGenerated*) that don't exist onComplexCollectionTypePropertyBuilder.Customer impact
Customers using bulk configuration of these facets for all properties get compilation errors in their generated migration snapshot files. The workaround is to manually remove the unsupported fluent API calls from the generated snapshot.
How found
Customer reported on EF 10. This is expected to affect a small part of developers using complex collections.
Regression
No. It only manifests when a new EF 10 feature is used.
Testing
Tests added.
Risk
Low. The targeted fix is to just avoid emitting invalid code for the affected scenarios.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.