Fix: Named query filters cannot override convention-set filters#37710
Merged
Fix: Named query filters cannot override convention-set filters#37710
Conversation
Pass ConfigurationSource.Explicit when creating QueryFilter in EntityTypeBuilder.HasQueryFilter(string, LambdaExpression) so that explicit configurations can override convention-set named query filters. Co-authored-by: roji <1862641+roji@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix named query filters not overriding convention filters
Fix: Named query filters cannot override convention-set filters
Feb 14, 2026
roji
approved these changes
Feb 14, 2026
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where named query filters set by conventions could not be overridden by explicit user configuration. The issue was that the public API method EntityTypeBuilder.HasQueryFilter(string, LambdaExpression) was not passing a ConfigurationSource when constructing the QueryFilter object, preventing proper configuration precedence checks.
Changes:
- Fix
EntityTypeBuilder.HasQueryFilterto passConfigurationSource.Explicitwhen creating named query filters, matching the pattern already used for unnamed filters - Add test verifying explicit configuration can override convention-set named query filters
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/EFCore/Metadata/Builders/EntityTypeBuilder.cs | Add ConfigurationSource.Explicit parameter to QueryFilter constructor for named filters |
| test/EFCore.Tests/Metadata/Internal/InternalEntityTypeBuilderTest.cs | Add test verifying convention-set named filters can be overridden by explicit configuration |
Member
|
@AndriySvyryd possibly take a look at #37708 (comment) while reviewing? Or we can treat that as a separate thing if better. |
Remove QueryFilter constructors that don't accept ConfigurationSource and make the ConfigurationSource property non-nullable. This ensures all QueryFilter instances have a valid configuration source for proper override behavior. Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
auto-merge was automatically disabled
February 17, 2026 19:24
Head branch was pushed to by a user without write access
AndriySvyryd
approved these changes
Feb 17, 2026
Copilot AI
added a commit
that referenced
this pull request
Feb 18, 2026
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot AI
added a commit
that referenced
this pull request
Feb 20, 2026
Co-authored-by: roji <1862641+roji@users.noreply.github.com>
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.
Fix Named Query Filter Override from Convention
EntityTypeBuilder.HasQueryFilter(string, LambdaExpression)doesn't set ConfigurationSourceEntityTypeBuilder.HasQueryFilterto pass ConfigurationSource.ExplicitOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.