Support forum for ASP.NET Zero (
By drblakl
#31542 Hello!

Using Asp.NET MVC 5 project and wondering what the best practice is to eager load required children of a Repository.

Do we need to make a custom repository to GetAllIncluding(), or is there another way that will load specific required children all the time if available?

Thank you in advance!
By ryancyq
#31546 Are you referring to EF6 or EFCore?

You can use GetAllIncluding() if you know the navigation properties to load in in advance.

However if you are looking to build a query and load the relevant navigation properties conditionally, you can try Include () followed by ThenInclude() available from EF Core APIs