不能使用.ToListAsync()扩展方法(.net 4.7) [英] Can not use .ToListAsync() extension method (.net 4.7)
问题描述
我正在尝试使用扩展方法.ToListAsync()
,但是由于某种原因,该扩展方法不适用于我.
Im am trying to use extension method .ToListAsync()
but for some reason this extension method not available for me.
我的设置如下:
- Web项目(.Net 4.7),我确实包含了
using System.Data.Entity;
- DataAcess项目(.Net 4.7)在这里我插入
Entity Frame Work v6.2
- Web Project (.Net 4.7) here i did include
using System.Data.Entity;
- DataAcess Project (.Net 4.7) here I interlude
Entity Frame Work v6.2
我的Web项目确实引用了我的DataAccess项目.
My Web Project does reference my DataAccess project.
我不确定我哪里出错了.有人可以请教吗?
Im not sure where i went wrong. Can somebody please advise?
谢谢!
推荐答案
The ToListAsync
method is part of the QueryableExtensions
class which is in the System.Data.Entity
namespace and part of the EntityFramework.dll
library. This means that you need import the namespace (i.e. using System.Data.Entity;
) as well as reference EntityFramework.dll
.
请注意,在经典的.Net Framework项目中,引用不是可传递的.换句话说,如果要使用库中的类,则必须在每个项目中都引用它.但在.Net Core中,这已经发生了变化.
Note that in classic .Net Framework projects, references are not transitive. In other words, if you want to use classes from a library, you must reference it in every project. This has changed in .Net Core though.
这篇关于不能使用.ToListAsync()扩展方法(.net 4.7)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!