6

what is the relation between lazyloadingenabled and proxycreationenabled in context configuration

public CorrespondenceContext()
        : base("DefaultConnection")
    {
        this.Configuration.LazyLoadingEnabled = true;
        this.Configuration.ProxyCreationEnabled = true;
    }

what i noticed is when ProxyCreationEnabled=false lazyloading missed its function that meaning that when this.Configuration.LazyLoadingEnabled = true; this.Configuration.ProxyCreationEnabled = false;

I have to use Include when using related objects

is ProxyCreationEnabled override LazyLoadingEnabled ??

Abraham Josef
  • 653
  • 1
  • 8
  • 30
  • 6
    You are right that LazyLoading does not work when `ProxyCreationEnabled == false`. This is because lazy loading works by adding additional code into your model classes to support lazy loading. This additional code is added by subclassing your model class, and the resulting subclass is called a proxy. By disabling the proxy creation, there is no hooks for EF to lazy load. In theory you could manually add them yourself and the two configs would be independent. – Aron Jun 18 '14 at 10:01
  • Quite a good answer here http://stackoverflow.com/questions/4596371/what-are-the-downsides-to-turning-off-proxycreationenabled-for-ctp5-of-ef-code-f – DavidG Jun 18 '14 at 10:01
  • @Aron. Your comment is the perfect answer. Why don't you rite it as answer instead of comment? – JotaBe Jun 18 '14 at 13:23
  • @Aron thank you for your answer, but if I make ProxyCreationEnabled=true and LazyLoadingEnable=false it runs as it=true and no need for include, what I understand that if ProxyCreationEnabled=true and lazyload =false so it is eagearload and I have to use include, please I need clarification – Abraham Josef Jun 18 '14 at 21:10

0 Answers0