dotnet/efcore · error · InvalidOperationException
The ' ' method is not supported because the query has…
Error message
The '{methodName}' method is not supported because the query has switched to client-evaluation. This usually happens when the arguments to the method cannot be translated to server. Rewrite the query to avoid client evaluation of arguments so that method can be translated to server. What it means
EF.Functions.Collate is a query-only extension: inside an EF LINQ query the relational provider translates it to a COLLATE expression; the method body throws CoreStrings.FunctionOnClient so any direct (client-side) invocation fails. Hitting it means the call fell out of translation and executed in memory.
Solutions
- Ensure EF.Functions.Collate is used only inside an IQueryable the EF provider translates (source from context.Set<T>()).
- Apply collation at the column/SQL level (e.g. column collation or raw SQL) instead of in a client-evaluated expression.
- Upgrade the EF Core relational provider to a version that supports Collate translation.
Example fix
// before: source is in-memory, so Collate executes client-side and throws
var rows = localList.Where(r => EF.Functions.Collate(r.Name, "SQL_Latin1") == query);
// after: query the DbContext so the provider translates
var rows = context.Items
.Where(r => EF.Functions.Collate(r.Name, "SQL_Latin1") == query)
.ToList(); Defensive patterns
Strategy: validation
Validate before calling
// Ensure EF.Functions.Collate runs inside a provider-translated query IQueryable<Item> q = context.Items; var result = q.Where(r => EF.Functions.Collate(r.Name, "SQL_Latin1") == query).ToList(); // Avoid calling Collate after AsEnumerable() or on in-memory sources.
Type guard
static bool IsEntityQuery<T>(IQueryable<T> q)
=> q.Provider.GetType().FullName?.Contains("EntityFrameworkCore", StringComparison.OrdinalIgnoreCase) == true; Prevention
- Keep EF.Functions calls inside provider-translated queryables.
- Do not insert AsEnumerable()/ToList() before EF.Functions usage.
- Apply collation at the column/SQL level for persistent behavior.
When it happens
Trigger: Calling EF.Functions.Collate(operand, collation) outside an EF-translated query, or where the provider could not translate it — e.g. on an in-memory IEnumerable, or on an unsupported operand/collation type.
Common situations: Mixing LINQ-to-Objects with EF queries so the provider stops translating; calling Collate in a unit test against a List; provider version lacking COLLATE translation; applying it to a computed/client-side value.
Related errors
- The 'EF.MultipleParameters
- The LINQ expression ' ' could not be translated. Either…
- The LINQ expression ' ' could not be translated. Additional…
- Async lambdas are not supported
- Could not find type symbol for
AI-assisted analysis of dotnet/efcore@3a2006ef56 (2026-08-11).
Data as JSON: /api/errors/110f4f17890b553c.
Report an issue: GitHub.
Appendix: source
Thrown at src/EFCore.Relational/Extensions/RelationalDbFunctionsExtensions.cs:35
/// <summary>
/// Explicitly specifies a collation to be used in a LINQ query. Can be used to generate fragments such as
/// <c>WHERE customer.name COLLATE 'de_DE' = 'John Doe'</c>.
/// </summary>
/// <remarks>
/// <para>
/// The available collations and their names vary across databases, consult your database's documentation for more
/// information.
/// </para>
/// <para>
/// See <see href="https://aka.ms/efcore-docs-database-functions">Database functions</see> for more information and examples.
/// </para>
/// </remarks>
/// <typeparam name="TProperty">The type of the operand on which the collation is being specified.</typeparam>
/// <param name="_">The <see cref="DbFunctions" /> instance.</param>
/// <param name="operand">The operand to which to apply the collation.</param>
/// <param name="collation">The name of the collation.</param>
public static TProperty Collate<TProperty>(this DbFunctions _, TProperty operand, [NotParameterized] string collation)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Collate)));
/// <summary>
/// Returns the smallest value from the given list of values. Usually corresponds to the <c>LEAST</c> SQL function.
/// </summary>
/// <param name="_">The <see cref="DbFunctions" /> instance.</param>
/// <param name="values">The list of values from which return the smallest value.</param>
public static T Least<T>(this DbFunctions _, [NotParameterized] params T[] values)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Least)));
/// <summary>
/// Returns the greatest value from the given list of values. Usually corresponds to the <c>GREATEST</c> SQL function.
/// </summary>
/// <param name="_">The <see cref="DbFunctions" /> instance.</param>
/// <param name="values">The list of values from which return the greatest value.</param>
public static T Greatest<T>(this DbFunctions _, [NotParameterized] params T[] values)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Greatest)));
/// <summary>View on GitHub (pinned to 3a2006ef56)