I am using .NET Core and EF Core 2.1.
I am using a very simple type query:
var entities = context.SomeEntity .Include(s => s.AnotherEntity) .ToList();
This works fine, but if
AnotherEntity has navigational properties, it loads those automatically. This is becoming a problem with very large applications because some of my web api calls are returning large amounts of data because the of all the nested entities.
Is this a model design problem or setting I can't find? I have not enabled lazy loading.
Turns out the problem was there were multiple other context calls within the same webapi action. If a navigation property existed on one of the other calls, it would load all navigation properties. I fixed it by adding .AsNoTracking().
You can read this documentation about lazy-loading.
Maybe you can solve your problem by using the proxies Nuget pacckage
Also, remember that navigation properties in your classes must be virtual.