Best place to enable lazy loading in entity framework 6

dbcontext entity-framework entity-framework-6

Question

What is the best place to keep lazyloading enable condition in my web application. Because when I am using database first approach of EF and when try to update the context then my all setting got wiped out. Below are my settings.

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

What is the best way so that these setting should not vanish after edmx update. Is there any chance to keep in global.asax. If yes what are its downsides?.

1
0
4/1/2015 1:53:50 PM

Popular Answer

Your placement looks fine. Note, that as Gert Arnold has stated, that these are defaulted to true.

So,

 public DBEntities(): base("name=DBEntities")
    { }

Is all you need for the sake of brevity here, excluding explicitness.

0
4/1/2015 2:04:07 PM


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