Open v-karnaukhov opened 1 year ago
Hello @v-karnaukhov ,
Unfortunately, even if we learned a lot from this issue, we didn't succeed in fixing it.
You can still achieve this by performing a LINQ on your side:
var temp = context.Requests
.Where(x => x.Id == 1)
.IncludeOptimizedByPath($"{nameof(Request.Meetings)}.{nameof(MeetingRequest.Votes)}.{nameof(Vote.Documents)}")
.IncludeOptimized(x => x.Meetings.SelectMany(x => x.Votes.SelectMany(x => x.Documents).Select(x => x.File)))
.FirstOrDefault();
Only the second IncludeOptimized
was not working to File
not being a collection.
At this moment, we will not try deeper to fix it as we currently don't progress anymore on it. We simply don't know how to fix it.
Best Regards,
Jon
Description
IncludeOptimizedByPathIssue throw error
"Method Microsoft.EntityFrameworkCore.Query.RelationalShapedQueryCompilingExpressionVisitor+ShaperProcessingExpressionVisitor.PopulateCollection: type argument 'System.Collections.Generic.List
1[System.Collections.Generic.List
1[IssueWithAnyAll.Entities.File]]' violates the constraint of type parameter 'TRelatedEntity'."Exact that code perfectly worked for EF 6, but now after upgrading to EF Core 7 it produce error.
In reproducing repo you can see this :
where IncludeOptimizedMultiple is extension :
Exception
Project
Reproducing repo is here : https://github.com/v-karnaukhov/z.entityframework.plus.issue. In repo you can find script for creating db structure (DB Scripts folder).
Further technical details