I have a query like this
return await _ctx.Activities
.Include(a => a.Attributes)
.Include(a => a.Roles)
.Include(a => a.Bookmarks)
.Include(a => a.VideoMetas)
.ThenInclude(vm => vm.Instances)
.Include(a => a.ImageMetas)
.ThenInclude(im => im.Instances)
.Include(a => a.Procedure)
.ThenInclude(p => p.Attributes)
.FirstOrDefaultAsync(a => a.Id == id);
Which turns out to be very slow. In EF 6 you can do .Include(v => v.VideoMetas.Select(vm => vm.Instances) which is a bit faster (I guess, haven't looked at SQL Profiler and actual query tbh). How can I optimize that? I can also use EF Plus where it has .IncludeOptimized() but there is no version for .ThenInclude(). I heard I can use .Select instead of .Include() but really not sure how I can handle that in this query.