The error means you are hitting current EF Core bug or limitation.

I changed .Take to .TakeLast and now I get the described error.

So you know what caused the issue. In general avoid LINQ methods having Last in name (like Last, LastOrDefault, TakeLast) - these have no direct equivalent in SQL world, hence have bigger chance to hit bugs/limitations (or just not supported) by query translators.

Instead, invert the ordering and use the corresponding First method.

Applying it to your case means replacing

.OrderBy(d => d.CreatedDate)


.OrderByDescending(d => d.CreatedDate)





Related Articles