Repository navigation
Conversation
Changed InvalidIncludeExpression error message from 'property access' to 'navigation property access' to clarify that Include only works with navigation properties, not regular/complex type properties. Added Include_complex_property test in ComplexTypeQueryTestBase to verify the improved error message when attempting to Include a complex type property.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Provider-specific overrides are needed to prevent existing test override checks from failing.
1 open finding
What changed in this PR
Clarifies that Include requires navigation-property access and adds regression coverage for complex properties.
Changes:
- Updates the
InvalidIncludeExpressionresource message. - Synchronizes the generated XML documentation.
- Adds complex-property
Includetest coverage.
| File | Summary |
|---|---|
test/EFCore.Specification.Tests/Query/ComplexTypeQueryTestBase.cs |
Adds invalid Include coverage; provider-specific overrides are needed for existing override checks. |
src/EFCore/Properties/CoreStrings.resx |
Clarifies the navigation-property requirement. |
src/EFCore/Properties/CoreStrings.Designer.cs |
Synchronizes the generated documentation. |
Files not reviewed (1)
- src/EFCore/Properties/CoreStrings.Designer.cs: Generated file
🧠 Review effort: Lite
Comment on lines
+113
to
+117
| [Theory, MemberData(nameof(IsAsyncData))] | ||
| public virtual async Task Include_complex_property(bool async) | ||
| => Assert.Equal( | ||
| CoreStrings.InvalidIncludeExpression("c.ShippingAddress"), | ||
| (await Assert.ThrowsAsync<InvalidOperationException>(() => AssertQuery( |
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 #33018
Description
Updated the
InvalidIncludeExpressionerror message from'property access'to'navigation property access'to clarify thatIncludeonly operates on navigation properties, not regular or complex type properties.When a user tries to use
Includeon a complex type property (e.g.context.Set<Customer>().Include(c => c.ShippingAddress)), the previous error message indicated that it does not represent a property access, which was misleading becauseShippingAddressis indeed a property—it just isn't a navigation property.Changes
src/EFCore/Properties/CoreStrings.resx: UpdatedInvalidIncludeExpressionstring resource.src/EFCore/Properties/CoreStrings.Designer.cs: Updated XML doc comment to match.test/EFCore.Specification.Tests/Query/ComplexTypeQueryTestBase.cs: AddedInclude_complex_propertytest verifying the improved exception message when attempting to include a complex property.