Would like a specific entity to have a navigation property eager loaded by default.
Is this a feature in EF5?
The default behavior of an Entity Framework is Lazy Loading, where a child entity is loaded only when it is accessed for the first time. It simply delays the loading of the related data, until you ask for it.
And Eager loading is the process whereby a query for one type of entity also loads related entities as part of the query, so that we don't need to execute a separate query for related entities. Eager loading is achieved using the Include() method.
Here is a related document you can refer to.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
I really struggled to find documentation this a while back, but it does exist on the NavigationBuilder property. It's now called "AutoInclude". Documentation here :
It's used like so :
builder.Navigation(x => x.Customer).AutoInclude();
A guide on it here incase you need to opt out too : https://dotnetcoretutorials.com/2021/03/07/eager-load-navigation-properties-by-default-in-ef-core/
4 people are following this question.