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;
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…