Skip to content

Compiled query is never cached when named query filters is used #37112

@WiseGus

Description

@WiseGus

Bug description

Hello,

I tried the new named global query filter feature, but it seems to have a problem with query caching when using its corresponding overload of IgnoreQueryFilters:

IgnoreQueryFilters(this IQueryable source, [NotParameterized] IReadOnlyCollection filterKeys)

CompiledQueryCacheKeyGenerator.GenerateCacheKey appears to always generate a new key, which leads to cache misses and query recompilation on each call.

This issue does not occur when using the previous overload:

IgnoreQueryFilters(this IQueryable source)

Your code

I have a minimal reproduction scenario available [here](https://github.com/WiseGus/ef10_named_filters_cache)  using Microsoft.EntityFrameworkCore.Sqlite

Note: It can be reproduced to both Microsoft.EntityFrameworkCore.Sqlite and Microsoft.EntityFrameworkCore.SqlServer.

Stack traces


Verbose output


EF Core version

10.0.0-rc.2.25502.107

Database provider

Microsoft.EntityFrameworkCore.Sqlite

Target framework

.NET 10.0

Operating system

Windows 11

IDE

Visual Studio 2026 Insiders 11201.2

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions