[5.0.3] Don't generate Fluent API in model snapshot for certain annotations #23852
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.
Fixes #23456, replaces #23847
Description
When generating the model snapshot for migrations, provider extension method calls generated for certain annotations are ambiguous across providers. This change replaces these ambiguous calls will direct reading of the associated metadata attribute, which was what we generated before 5.0, and is what we still generate for unknown annotations.
Customer Impact
When both SQL Server and Npgsql are used, fluent API calls are mismatched, leading to incorrect migration logic. Specifically, the same migration code is scaffolded again and again because the previous code doesn't work correctly. (Note that most cases cause compiler warnings. However, for some attributes there are different numbers of parameters on the extension methods, which causes the compiler to silently choose the incorrect one.)
How found
Reported by multiple customers on 5.0.x releases.
Test coverage
We have added test coverage in this PR. We have also done due diligence to find any other annotations that have this same issue.
Regression?
Yes.
Risk
Low. Only affects the design-time model context generation for migrations (no runtime impact).