Thursday 24 May 2012

Side effect of DbContextConfiguration.ProxyCreationEnabled Property

This does not seem to be documented anywhere on MSDN, that is why I would like to write a a quick post about it.

The example:

CustomerContext context = new CustomerContext();
context.Configuration.ProxyCreationEnabled = false;
var customers = context.Customers.ToList();


If DbContextConfiguration.ProxyCreationEnabled property is set to false, dbcontext will not load customers child objects unless Include method is called on customers object. Setting DbContextConfiguration.LazyLoadingEnabled property to true or false will have no impact on its behaviours.

If DbContextConfiguration.ProxyCreationEnabled is set to true, customers' child objects will be loaded automatically, and DbContextConfiguration.LazyLoadingEnabled value will control when child objects are loaded.


2 comments:

  1. Thank you, it is a good explanation for this issue.

    ReplyDelete
  2. Casino Finder (Google Play) Reviews & Demos - Go
    Check Casino Finder (Google Play). A kadangpintar look at poormansguidetocasinogambling.com some septcasino of the best 토토 사이트 gambling sites in the world. They offer gri-go.com a full game library,

    ReplyDelete