EF Core 3 x.Contains() in expression where x is ICollection

When you cast to IEnumerable() or List() EFCore forces Client side evaluation, which is why it works. (but works at a performance cost)

  • "Prior to version 3.0, Entity Framework Core supported client evaluation anywhere in the query" Reference
  • Version of EFCore prior to 3.0 also allowed you to add a warning if you mixed Server and Client evaluation.
  • Then EF changed policy to not allow you to mix Server and Client evaluation, so accidental performance issues don't happen. It's a little more complicated than that though, so here is a link to EFCore 3.1 breaking changes *All other versions can be found here as well in the left menu navigation, including 3.0.

I've run into the same issue, when migrating to EF Core 3.0 from 2.2. I've had ef configured before to throw error on client side evaluation, and it was working fine. So I'm sure it's a new issue with 3.0, introduced when they've rewritten the linq engine.

Casting it to either IEnumerable or List works for me as well, thanks for the tip!


This is a known bug fixed in 3.1. 3.0 is almost unusable due to all regressions after the query pipeline rewrite.

I recommend following the issue tracker on github for ef core.

https://github.com/dotnet/efcore/pull/17599