Closed pella-ias closed 1 year ago
Hello, I am having exactly the same issue on e project, I confirm removing either the collection or the json column works but that's that's not an option in my situation. Is there any known workaround for this (other then not getting one of them)?
@maumar Any workaround here?
problem comes from the bad interaction between json materializer code and the collection result coordinator. Fails for any collection (List, Array etc) not only ICollection interface.
@meigetsu @pella-ias workaround is to project entire entity and use include to bring back the related collection, rather than project the collection directly. Include uses slightly different path which is not affected by the bug.
Something like this:
var list = ctx.TestEntities
.AsNoTracking()
.Include(x => x.ChildEntities)
.ToList()
.Select(t => new TestEntity()
{
Id = t.Id,
JsonColumn = t.JsonColumn,
ChildEntities = t.ChildEntities,
}).ToList();
@ajcvickers second customer report on this issue - patch candidate or shall we wait for a few more?
Removing either the Json column or the collection from the projection solves the issue.
Minimal code to reproduce the error:
Stack trace:
I've found a possibly related issue on the dotnet runtime https://github.com/dotnet/runtime/issues/56262
EF Core version: 7.0.2 Database provider: Microsoft.EntityFrameworkCore.SqlServer Target framework: net7.0 (sdk 7.0.102) Operating system: Win 10 IDE: VSCode