Fix comparison to null for split entities#37358
Merged
roji merged 2 commits intodotnet:mainfrom Jan 3, 2026
Merged
Conversation
AndriySvyryd
reviewed
Jan 3, 2026
AndriySvyryd
approved these changes
Jan 3, 2026
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #35293 by adding support for null comparisons on split entities. Previously, the code failed when comparing a split entity to null because it didn't handle the multiple table mappings that result from entity splitting.
Key Changes
- Modified the null comparison logic to detect and handle entity splitting scenarios by selecting the principal table when multiple table mappings exist
- Added test coverage to verify that comparing split entities to null generates correct SQL with proper INNER JOINs
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.StructuralEquality.cs |
Replaced the single mapping lookup with a switch expression that handles both single mappings and entity splitting (multiple mappings) by selecting the principal table |
test/EFCore.Relational.Specification.Tests/Query/EntitySplittingQueryTestBase.cs |
Added base test that verifies split entity null comparisons work correctly with a simple entity splitting configuration |
test/EFCore.SqlServer.FunctionalTests/Query/EntitySplittingQuerySqlServerTest.cs |
Added SQL Server-specific test override that validates the generated SQL correctly performs INNER JOINs between main and split tables |
roji
added a commit
to roji/efcore
that referenced
this pull request
Mar 24, 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.
Fixes #35293