{"record":{"id":"110f4f17890b553c","repo":"dotnet/efcore","slug":"the-methodname-method-is-not-supported-because-110f4f","errorCode":null,"errorMessage":"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.","messagePattern":"The '(.+?)' 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\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Extensions/RelationalDbFunctionsExtensions.cs","lineNumber":35,"sourceCode":"    /// <summary>\n    ///     Explicitly specifies a collation to be used in a LINQ query. Can be used to generate fragments such as\n    ///     <c>WHERE customer.name COLLATE 'de_DE' = 'John Doe'</c>.\n    /// </summary>\n    /// <remarks>\n    ///     <para>\n    ///         The available collations and their names vary across databases, consult your database's documentation for more\n    ///         information.\n    ///     </para>\n    ///     <para>\n    ///         See <see href=\"https://aka.ms/efcore-docs-database-functions\">Database functions</see> for more information and examples.\n    ///     </para>\n    /// </remarks>\n    /// <typeparam name=\"TProperty\">The type of the operand on which the collation is being specified.</typeparam>\n    /// <param name=\"_\">The <see cref=\"DbFunctions\" /> instance.</param>\n    /// <param name=\"operand\">The operand to which to apply the collation.</param>\n    /// <param name=\"collation\">The name of the collation.</param>\n    public static TProperty Collate<TProperty>(this DbFunctions _, TProperty operand, [NotParameterized] string collation)\n        => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Collate)));\n\n    /// <summary>\n    ///     Returns the smallest value from the given list of values. Usually corresponds to the <c>LEAST</c> SQL function.\n    /// </summary>\n    /// <param name=\"_\">The <see cref=\"DbFunctions\" /> instance.</param>\n    /// <param name=\"values\">The list of values from which return the smallest value.</param>\n    public static T Least<T>(this DbFunctions _, [NotParameterized] params T[] values)\n        => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Least)));\n\n    /// <summary>\n    ///     Returns the greatest value from the given list of values. Usually corresponds to the <c>GREATEST</c> SQL function.\n    /// </summary>\n    /// <param name=\"_\">The <see cref=\"DbFunctions\" /> instance.</param>\n    /// <param name=\"values\">The list of values from which return the greatest value.</param>\n    public static T Greatest<T>(this DbFunctions _, [NotParameterized] params T[] values)\n        => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Greatest)));\n\n    /// <summary>","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Extensions/RelationalDbFunctionsExtensions.cs#L17-L53","documentation":"EF.Functions.Collate is a query-only method whose body throws InvalidOperationException(CoreStrings.FunctionOnClient) if it is ever executed on the client. EF is supposed to translate it to a SQL COLLATE clause; the throw fires only when translation fails and EF evaluates the expression client-side.","triggerScenarios":"Using EF.Functions.Collate(operand, collation) in a query where the operand or surrounding expression cannot be translated, causing client evaluation (RelationalDbFunctionsExtensions.cs:34-35). Also if invoked outside a query entirely.","commonSituations":"Collate applied to a client-computed value rather than an entity property; wrapped in an un-translatable method; used after AsEnumerable; provider that lacks collation translation; collation name built dynamically in a non-translatable way.","solutions":["Apply Collate directly to an entity property inside the translated query: ctx.Users.Where(u => EF.Functions.Collate(u.Name, \"de_DE\") == input).","Remove client-side wrappers around the operand so the whole predicate is server-translatable.","Ensure the call is before any AsEnumerable()/ToList() that switches to client evaluation.","If the collation must be applied client-side, do the comparison in .NET instead of via Collate."],"exampleFix":"// before\nvar names = GetNames();\nvar q = ctx.Users.Where(u => names.Contains(EF.Functions.Collate(u.Name, \"de_DE\")));\n// un-translatable -> client eval -> throws\n\n// after\nvar q = ctx.Users\n    .Where(u => EF.Functions.Collate(u.Name, \"de_DE\") == input);\n// or pre-filter client values, keep Collate on the property only","handlingStrategy":"validation","validationCode":"// Ensure Collate is only used inside the translated query on a property\nvar q = ctx.Users\n    .Where(u => EF.Functions.Collate(u.Name, \"de_DE\") == input);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Apply Collate to entity properties, not client values.","Keep Collate before any AsEnumerable/ToList boundary.","Confirm the provider translates collation for that expression shape."],"tags":["efcore","linq","client-evaluation","dbfunctions","collation"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}