[.NetCore/EF] Unable to translate collection subquery in projection since the parent query doesn't project key columns of all of it's tables which are required to generate results on client side.

我在.net5.0时使用ThenInclude 遇到的一个出现在.Net5.0的问题,在3.x时未出现。

InvalidOperationException:Unable to translate collection subquery in projection since the parent query doesn't project key columns of all of it's tables which are required to generate results on client side.

一开始我的解决方法是写一个GroupJoin 来代替ThenInclude ,但是发现太麻烦了,怕以后会出现很多类似的错误,感觉5.0还不太稳定,最后决定重新使用3.1。

好消息是目前没有使用5.0的新特性,所以主要工作是修改依赖。

Ref:

原文地址:https://www.cnblogs.com/zhonglinchen/p/14370611.html