EF 6.1 Difference between ProxyCreationEnabled and LazyLoadingEnabled

c# entity-framework

Question

In your DbContext you can configure the following two parameters:

context.Configuration.ProxyCreationEnabled = true;
context.Configuration.LazyLoadingEnabled = true;

My understanding is that to enable lazy loading you have to be able to create proxies for the entities. In other words both parameters need to be set to true to enable lazy loading.

1. Why do both parameters exist and why can you configure both parameters?

2. What would the effect of the following configurations be?

// Can't create proxies but can lazy load
context.Configuration.ProxyCreationEnabled = false;
context.Configuration.LazyLoadingEnabled = true;

// Can create proxies but can't lazy load
context.Configuration.ProxyCreationEnabled = true;
context.Configuration.LazyLoadingEnabled = false;
1
12
9/8/2014 8:22:04 AM

Popular Answer

AFAIK:

  • proxy creation true and lazy loading true =>
    • change tracking
    • lazy loading
  • proxy creation true and lazy loading false =>
    • change tracking
  • proxy creation false and lazy loading true =>
    • ...

reference (among others): msdn

10
9/8/2014 8:30:26 AM


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