Im am trying to use extension method .ToListAsync()
but for some reason this extension method not available for me.
My set up as follows:
- 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
My Web Project does reference my DataAccess project.
Im not sure where i went wrong. Can somebody please advise?
Thank you!
While the
.ToListAsync()
method is made available by referencing the EntityFramework.dll andusing System.Data.Entity;
, it is only available on types that implement theIQueryable
interface.An example of it being used:
As a note, if you can't see the
ToListAsync()
method, you may be missing theusing System.Data.Entity;
in your class.The
ToListAsync
method is part of theQueryableExtensions
class which is in theSystem.Data.Entity
namespace and part of theEntityFramework.dll
library. This means that you need import the namespace (i.e.using System.Data.Entity;
) as well as referenceEntityFramework.dll
.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.