EF Core Eager loading performance extremely slow

554 Views Asked by At

I perform eager loading in production and it extremely slow it will get the website not responding here is my sample code

AppDbContext.Employees
        .Include(e => e.Employments)
            .ThenInclude(e => e.Department)
        .Include(e => e.Employments)
            .ThenInclude(e => e.Position)
        .Where(predicate).Tolist();

I Take(20) records of employee each employee has 5 - 10 employment records and each employment record i include the department and position. Why i take so long to retrieve the data?

0

There are 0 best solutions below