Can't seem to find any mention of this for EF Core. I've found examples to disable lazy loading in prior EF versions. I have an asp.net core, MVC6, Web Api, and AngularJS site I'm working on.
In the app, I have a table Members and a table MemberStateActions which has a foreign key reference to the Members table. I'm selecting the data using the query below, and then returning the data via Web Api call as Json return type. The resulting MemberStateActions object returned via Web Api has the MemberStateAction.Member object populated. I did not eager load the Member data using .include. I did not lazy load the Member object by calling the property. I don't understand why the Member data is automatically populated. I've read that json serialization maybe be calling the member property causing the lazy loading of the member data before being sent in the Web Api response. Not sure if this is the cause.
Bottom line, I'm looking on some direction as to how to prevent this automatic loading of the member object. Possibly by disabling lazy loading?
var q = (from x in _context.MemberStateAction
where x.MemberId == memberID
select x);
return q;
Entity Framework Core does not have lazy loading implemented at this time (RTM Build).
It is recommended that you do eager loading by using an .Include extension method. It is also a good idea to use a repository to do the eager loading for you.
Reference: https://github.com/aspnet/EntityFramework/issues/3797