How long is "takes forever"? How many records are returned? Can you provide the table schema and/or entity design? Maybe you need to add an index on the DeptRoles table?
Entity FrameWork6 Load takes forever
Benjoe
431
Reputation points
I have a query which calls Load() after and it takes forever. Is there anyway I can optimize it. Below is my query
var EmpUsers = data.DeptRoles
.Include(x => x.ROLE)
.Include(x => x.USER)
.Where(x => x.Id == deptId && x.USER.Inactive == false);
EmpUsers.Load(); -----> this takes forever
2 answers
Sort by: Most helpful
-
-
Benjoe 431 Reputation points
2022-03-23T12:24:41.687+00:00 I have fixed the issue myself.
var EmpUsers = data.DeptRoles;
var roles = EmpUsers .Include(x => x.ROLE);
var newUsers = roles.Include(x => x.USER)
.Where(x => x.Id == deptId && x.USER.Inactive == false);
newUsers.Load();