Redo model validation to stop looping for every check#37646
Merged
roji merged 2 commits intodotnet:mainfrom Feb 12, 2026
Merged
Redo model validation to stop looping for every check#37646roji merged 2 commits intodotnet:mainfrom
roji merged 2 commits intodotnet:mainfrom
Conversation
b9272a8 to
f025731
Compare
There was a problem hiding this comment.
Pull request overview
Refactors EF Core model validation to avoid repeated full-model iterations by validating per-entity (and per-member) in a single pass, and updates provider-specific validators/tests to align with the new validation flow.
Changes:
- Refactored
ModelValidatorto perform validation via a single iteration over entity types and added per-entity/per-property/per-index extension points. - Updated relational, SQL Server, SQLite, and Cosmos validators to plug into the new per-entity/per-member validation pipeline.
- Adjusted tests across providers to reflect new validation behavior (e.g., discriminator setup, stored-procedure unsupported behavior, decimal warning handling).
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/EFCore/Infrastructure/ModelValidator.cs |
Core refactor to validate entity types in one pass; introduces per-entity/property/index/trigger validation hooks. |
src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs |
Moves many relational validations into per-entity/per-property/per-key overrides; adds stored procedure sharing and sequence validation. |
src/EFCore.SqlServer/Infrastructure/Internal/SqlServerModelValidator.cs |
Splits SQL Server validations into per-entity/per-property/per-index checks (temporal, decimal, vector, include properties). |
src/EFCore.Sqlite.Core/Infrastructure/Internal/SqliteModelValidator.cs |
Updates SQLite validation to run per-entity and per-sequence and to throw for stored procedures early. |
src/EFCore.Cosmos/Infrastructure/Internal/CosmosModelValidator.cs |
Reorganizes Cosmos validations into per-entity/per-property/per-index/trigger overrides. |
test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs |
Updates inheritance-related tests to explicitly configure discriminators. |
test/EFCore.Relational.Tests/Infrastructure/RelationalModelValidatorTest.cs |
Adjusts entity-splitting test to use a derived-type property. |
test/EFCore.Sqlite.Tests/Infrastructure/SqliteModelValidatorTest.cs |
Overrides additional stored-procedure tests to expect SQLite “not supported” behavior. |
test/EFCore.SqlServer.FunctionalTests/PropertyValuesSqlServerTest.cs |
Sets explicit column types for decimal properties inside complex types. |
test/EFCore.SqlServer.FunctionalTests/LazyLoadProxySqlServerTest.cs |
Ignores DecimalTypeDefaultWarning via fixture options. |
test/EFCore.SqlServer.FunctionalTests/ComplexTypesTrackingSqlServerTest.cs |
Uses primary constructor for base test class and ignores DecimalTypeDefaultWarning. |
test/EFCore.Relational.Specification.Tests/Query/AdHocAdvancedMappingsQueryRelationalTestBase.cs |
Changes complex-type payment fields from decimal to double. |
.../EFCore.Relational.Specification.Tests/Query/AdHocAdvancedMappingsQueryRelationalTestBase.cs
Show resolved
Hide resolved
b68b62d to
abba36e
Compare
.../EFCore.Relational.Specification.Tests/Query/AdHocAdvancedMappingsQueryRelationalTestBase.cs
Show resolved
Hide resolved
test/EFCore.Tests/Metadata/Internal/InternalEntityTypeBuilderTest.cs
Outdated
Show resolved
Hide resolved
a714ed7 to
272ebfd
Compare
AndriySvyryd
approved these changes
Feb 12, 2026
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.
@AndriySvyryd there's some additional potential cleanup/refactor, but this is a solid 1st step - let me know what you think. I suggest we iterate here with whatever works fastest, i.e. if you want changes, it's probably better to check this out and do them (or ask copilot to do them) rather than comment (as this more your owned area in any case). But am open to doing it in whatever way you prefer.
Closes #37645