A load can only be called when the EntityCollection or EntityReference does not contain objects

As the name implies, when I use lazyload Entity Framework 4.1, which disabled tracking, I got an error.

Full error message:

When an object returns with the NoTracking merge parameter, Load can only be called when the EntityCollection or EntityReference does not contain objects

Does anyone know why?

+4
source share
2 answers

Set the Configuration.ProxyCreationEnabled field of your DbContext to false :

 using (var dbContext = MyDbContext()) { dbContext.Configuration.ProxyCreationEnabled = false; return dbContext.MyProducts.AsNoTracking().Where(product => product.DepartmentId = departmentId); } 
+3
source

I have the same problem too. Apparently this is a bug in EF 4.1 Big Ticket

0
source

Source: https://habr.com/ru/post/1383377/


All Articles