As Title showed, When I use lazyload of Entity Framework 4.1 which turned tracking off I got the error.
Complete exception message:
When an object is returned with a NoTracking merge option, Load can only be called when the EntityCollection or EntityReference does not contain objects
Does anyone knows why?
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);
}