Eager Loading in Entity Framework Core 2.2

丶灬走出姿态 提交于 2020-06-01 05:52:45

问题


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>

回答1:


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;


来源:https://stackoverflow.com/questions/53906183/eager-loading-in-entity-framework-core-2-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!