简体   繁体   English

实体框架核心2.2中的急切加载

[英]Eager Loading in Entity Framework Core 2.2

Have Entity Framework Core 2.2 removed Eager Loading? 有实体框架的核心2.2取出预先加载? 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..." include方法不会出现在Visual Studio intellisense中,当我手动编写它时,它会给出一个错误:“它不包含'include'的定义,也没有可访问的扩展...”

Example

School school = _context.Students.Include... 

My demo is made with a simple ASP Core 2.2. 我演示用一个简单的ASP核心2.2制作。 Web Application. Web应用程序。 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>

Have Entity Framework Core 2.2 removed Eager Loading? 有实体框架的核心2.2取出预先加载?

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..." include方法不会出现在Visual Studio intellisense中,当我手动编写它时,它会给出一个错误:“它不包含'include'的定义,也没有可访问的扩展...”

Looks like you are missing the following using statement in your code : 看起来您在代码中缺少以下using语句:

using Microsoft.EntityFrameworkCore;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM