The LINQ expression could not be translated 🟪 .NET

EF Core: The LINQ expression 'x' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly

The query uses C# code EF Core can’t convert to SQL — custom methods, unsupported string/date functions, or complex projections.

Seen on: .NET

Meaning

EF Core 3+ throws instead of silently evaluating on the client. Rewrite with translatable operations, move the custom part after AsEnumerable(), or use EF.Functions.

Common causes

  • Calling your own methods inside Where/Select
  • Unsupported string comparisons (StringComparison) or formatting
  • GroupBy shapes EF can’t translate

⚡ Quick fix

  1. Rewrite using translatable expressions (EF.Functions.Like, simple comparisons)
  2. Filter in SQL first, then AsEnumerable() for client-side parts
  3. Use raw SQL for complex queries

Detailed fix by platform

C#

  1. csharp
    var rows = await db.Users
        .Where(u => EF.Functions.Like(u.Email, "%@example.com"))
        .ToListAsync();
    var view = rows.Select(u => Format(u));   // client-side after materialising

How to diagnose

  1. Expression — Part named in the message
  2. Version — EF Core version (translation support grows)

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.