I cant seem to figure out how to get EF Core to include / load related objects when using SelectMany.
context.MyObject
.Where(w => w.Id == Id)
.SelectMany(m => m.SubObject)
.Include(i => i.AnotherType)
Would have thought something like the above would work, however the collapsed SubObject collection has the AnotherObject being null and not included.
Been searching for hours.
Any help would be appreciated.
Thanks
It used to work in EF6, but currently is not supported by EF Core - it allows you to use eager load only the entity which the query starts with, as mentioned in the Loading Related Data - Ignored Includes section of the documentation:
So to get the eager loading work in your scenario, the query should be like this (assuming you have inverse navigation or FK property in
SubObject
):