When the EntityCollection or EntityReference does not contain any objects, load is called.

entity-framework

Question

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?

1
4
11/28/2011 6:18:50 AM

Popular Answer

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
12/16/2015 8:01:58 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow