Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
397 views
Welcome To Ask or Share your Answers For Others

1 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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...