Repository navigation
Don't let [NotMapped] on an explicit interface implementation ignore a public member - #39499
Merged
AndriySvyryd merged 1 commit intoNov 3, 2026
Conversation
…a public member - NotMappedMemberAttributeConvention ignores members by simple name, so the attribute on IFoo.Covers also ignored the public Covers - Skip the ignore when the type has another member with that name, for entity and complex types Fixes dotnet#34242
AndriySvyryd
approved these changes
Nov 3, 2026
AndriySvyryd
left a comment
Member
There was a problem hiding this comment.
Thanks for your contribution!
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 #34242
NotMappedMemberAttributeConventionsees the attribute on the explicit implementation, whose member name isIBookCover2Haver.Covers, and callsIgnorewithGetSimpleMemberName(), which isCovers. The ignore then removes the publicCoversnavigation, andInclude(x => x.Covers)throws.The convention now skips the ignore when the member's simple name differs from its full name and the type has another property or field with that simple name. Both the entity type and complex type paths do this. If there's no such member, nothing changes, so
NotMappedAttribute_ignores_explicit_interface_implementation_propertystill passes.If the public member should be ignored too, it can have its own
[NotMapped].Added
NotMappedAttribute_on_explicit_interface_implementation_does_not_ignore_public_membertoDataAnnotationTestBase. It covers a scalar property, a navigation and a property on a complex type, and fails without the change.EFCore.Tests,DataAnnotationInMemoryTestand the in-memory model builder tests pass with it.