dotnet / dotnet/efcore

Regression: Array column querying broken in EFC 11.0.0-rc.1.26425.128

Closed
#38,993 0 comments 0 reactions 0 assignees View on GitHub
customer-reported
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

### Bug description

```
InvalidOperationException: The LINQ expression 'DbSet()
.Where(b => b.IsVisible)
.Where(b => b.ContentBlockId == null)
.Where(b => b.Hashtags
.Intersect(@tags)
.Any())' could not be translated. Additional information: Translation of method 'System.Linq.Enumerable.Intersect' failed. If this method can be mapped to your custom function, see https://go.microsoft.com/fwlink/?linkid=2132413 for more information. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
```

the same happens with `.Where(b => b.Hashtags.Any(h => tags.Contain(h)))`. Those were perfectly translatable queries before, but alas, they aren't any more.

### Your code

https://github.com/Genfic/Ogma/blob/340091718bce2f9982e55b6cc935cb55d6283258/Ogma3.Data/Blogposts/Blogpost.cs

```cs
public sealed class Blogpost
{
// ...
public string[] Hashtags { get; set; } = [];
}
```

https://github.com/Genfic/Ogma/blob/340091718bce2f9982e55b6cc935cb55d6283258/Ogma3.Data/Blogposts/BlogpostConfiguration.cs

```cs
builder
.HasIndex(b => b.Hashtags)
.HasMethod(PgConstants.IndexTypes.Gin)
.HasFilter($"\"{nameof(Blogpost.IsVisible)}\"")
.UseCollation(PgConstants.CollationNames.CaseInsensitiveNoAccent);
```

Query proper is in https://github.com/Genfic/Ogma/blob/340091718bce2f9982e55b6cc935cb55d6283258/Ogma3/Pages/Blog/Index.cshtml.cs

### Stack traces

```text
System.InvalidOperationException: The LINQ expression 'DbSet()
.Where(b => b.IsVisible)
.Where(b => b.ContentBlockId == null)
.Where(b => b.Hashtags
.Intersect(@tags)
.Any())' could not be translated. Additional information: Translation of method 'System.Linq.Enumerable.Intersect' failed. If this method can be mapped to your custom function, see https://go.microsoft.com/fwlink/?linkid=2132413 for more information. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.Translate(Expression expression)
at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutorExpression[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass11_0`1.b__0()
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteCore[TResult](Expression query, Boolean async, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync[TResult](Expression query, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ExecuteAsync[TSource,TResult](MethodInfo method, IQueryable`1 source, Expression additionalArgument, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ExecuteAsync[TSource,TResult](MethodInfo method, IQueryable`1 source, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.CountAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at Ogma3.Pages.Blog.IndexModel.OnGetAsync(String q, Nullable`1 sort, Int32 page) in F:\VS Projects\Ogma3\Ogma3\Pages\Blog\Index.cshtml.cs:line 81
at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.GenericTaskHandlerMethod.Convert[T](Object taskAsObject)
at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.GenericTaskHandlerMethod.Execute(Object receiver, Object[] arguments)
at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeHandlerMethodAsync()
at System.Runtime.CompilerServices.AsyncHelpers.TransparentAwait(Task task)
at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeNextPageFilterAsync()
at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Rethrow(PageHandlerExecutedContext context)
at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ExceptionContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeNextResourceFilter()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location ---
at System.Runtime.CompilerServices.AsyncHelpers.TransparentAwait(Task task)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Ogma3.Infrastructure.Middleware.UserBanMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) in F:\VS Projects\Ogma3\Ogma3\Infrastructure\Middleware\UserBanMiddleware.cs:line 45
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.b__0(HttpContext context)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
at Ogma3.Infrastructure.Middleware.AddHeadersMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) in F:\VS Projects\Ogma3\Ogma3\Infrastructure\Middleware\AddHeadersMiddleware.cs:line 18
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.b__0(HttpContext context)
at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.InvokeCore(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
```

### Verbose output

```text

```

### EF Core version

11.0.0-rc.1.26425.128

### Database provider

Npgsql.EntityFrameworkCotre.PostgreSQL

### Target framework

.NET 11 RC.1

### Operating system

Windows 11

### IDE

JetBrains Rider 2026.2.1

Contributor guide

Open the contributing guide

Research direction

Start with the Hashtags property and configuration in Ogma3.Data/Blogposts/Blogpost.cs and BlogpostConfiguration.cs, then inspect the query in Ogma3/Pages/Blog/Index.cshtml.cs. Reproduce the Intersect and Any/Contains queries against the reported EF Core and PostgreSQL versions, and trace the translation regression. Done means array-column queries translate and execute as they did before 11.0.0-rc.1.26425.128.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, postgresql
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.