Entity framework 在我的EF实现泛型存储库中找不到.Include()方法

Entity framework 在我的EF实现泛型存储库中找不到.Include()方法,entity-framework,repository-pattern,Entity Framework,Repository Pattern,我正在使用泛型存储库包装上层的DbContext和DbSet类。 但是,在某些查询中,我需要使用“.Include()”方法来包含导航属性。但我无法在repository方法returing IQueryable上找到这些方法 像 this.repository.GetQuery<GeneralCalendarDates>() this.repository.GetQuery() 虽然我可以在这里使用.ToList(),但它没有include方法 知道这里有什么问题吗?Inclu

我正在使用泛型存储库包装上层的DbContext和DbSet类。 但是,在某些查询中,我需要使用“.Include()”方法来包含导航属性。但我无法在repository方法returing IQueryable上找到这些方法

this.repository.GetQuery<GeneralCalendarDates>()
this.repository.GetQuery()
虽然我可以在这里使用.ToList(),但它没有include方法


知道这里有什么问题吗?

Include
for
IQueryable
是一种扩展方法,在程序集
EntityFramework.dll
中的命名空间
System.Data.Entity
中实现。因此,您的项目必须引用此程序集,并且必须添加

using System.Data.Entity;
在代码文件的开头。它将使基于字符串和lambda的
Include
版本可用,以便您可以使用:

orderQuery.Include("Customer")


或使用Microsoft.EntityFrameworkCore;如果.NET内核
orderQuery.Include(o => o.Customer)