How to turn off lazy loading in entity framework?

devquora
devquora

Posted On: Feb 22, 2018

 

Lazy loading can be turned off for a particular context or an entity. To turn off the lazy loading for a specific property, do not convert it to the virtual. To disable the lazy loading for the entire entities in a context, the configuration property must be set to false. Now let us see the ways for turning off the lazy loading.

  • Context.configuration.ProxyCreationEnabled should be true. Context.Confiuration.LazyLoadingEnabled should be made true.
  • Navigation property should not be defined as virtual and public. The context will do the lazy loading if the property is defined as virtual.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    Entity framework interview questions

    Explain what is Entity Framework?

    Entity Framework happens to be an open-source ORM or object-relational mapping framework utilized for ADO.Net. It is a set of mechanization that assists in the improvement of data-oriented software ad...

    Entity framework interview questions

    What is new in entity framework 7?

    The new features in entity framework 7 include the following:New platforms: .NET along with the other distinct technologies like WPF, ASP.NET, WinForms is supported by Entity Framework 7.  E...

    Entity framework interview questions

    How to check installed version of Entity Framework?

    To check, If you open up the reference file and detect system.entity.data, click the module and then inspect the runtime version numerical in the Properties explorer and you can witness the subversion...