Search code examples
asp.net-coreentity-framework-coreeager-loading

Eager Loading in Entity Framework Core 2.2


Have Entity Framework Core 2.2 removed Eager Loading? The include method won't appear in Visual Studio intellisense, and when I write it manually it gives an error: "it does not contain a definition for 'Include' and no accessible extensions..."

Example

School school = _context.Students.Include... 

My demo is made with a simple ASP Core 2.2. Web Application. Not much have been changed. The project use this packages:

<ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.0" />
  </ItemGroup>

Solution

  • Have Entity Framework Core 2.2 removed Eager Loading?

    No, it still exists.

    The include method won't appear in Visual Studio intellisense, and when I write it manually it gives an error: "it does not contain a definition for 'Include' and no accessible extensions..."

    Looks like you are missing the following using statement in your code:

    using Microsoft.EntityFrameworkCore;