Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to globally disable lazy loading in Entity Framework 7?

It seems like this way is no longer available.

public ApplicationDbContext()
{
    this.Configuration.LazyLoadingEnabled = false;
}
like image 426
Piotrek Avatar asked Jan 01 '16 12:01

Piotrek


People also ask

How can you disable lazy loading for all entities?

We can disable lazy loading for a particular entity or a context. To turn off lazy loading for a particular property, do not make it virtual. To turn off lazy loading for all entities in the context, set its configuration property to false.

How do I turn off eager loading in Entity Framework?

In EF Core: context. ChangeTracker. LazyLoadingEnabled = false; Per this answer.

How do I get rid of lazy loading?

To disable lazy loading on a specific post or page, open the post or page, and in the “Cache Options” meta box, un-check the “LazyLoad for images” option. Don't forget to publish or update the post or page to save your changes.

How do I enable lazy loading in Entity Framework?

Lazy loading means delaying the loading of related data, until you specifically request for it. When using POCO entity types, lazy loading is achieved by creating instances of derived proxy types and then overriding virtual properties to add the loading hook.


1 Answers

Lazy loading does not (currently) exist in EF7, so there is no API to disable it https://github.com/aspnet/EntityFramework/issues/3797

like image 94
ErikEJ Avatar answered Oct 07 '22 02:10

ErikEJ