By default, EF Core doesn't support to filter in the
Disclaimer: I'm the owner of the project Entity Framework Plus
The EF+ Query IncludeFilter (free and open source) allows easily filter included entities.
ThenInclude is not yet supported but you just have to include the last filter to have the same behavior.
_dbContext.User .IncludeFilter(x=>x.UserRoles) .IncludeFilter(x=>x.UserRoles.SelectMany(y => y.Roles.Where(z => z.Active)))