I recently have a project with MVC 4, .NET 4.5 and using EF 5.0 (Database First) using the EF 5.0 DbContext Generator. I then upgraded through Nuget Manager to EF 6.0 alpha 2. I wanted to use the new async patterns but for some reason I dont have .ToListAsync() available. I am referencing the context in a similiar fashion:
public class HomeController : Controller
{
TestContext db = new TestContext();
public async Task<ActionResult> Index()
{
var keywords = await db.Keywords.ToListAsync();
return View(keywords);
}
}
Is this not available in Database First, and only available in Code First? How can I make something like the example above work? I am using SQL Azure.
Async. extension methods are defined in EF related System.Data.Entity.IQueryableExtensions
static class. So you must add:
using System.Data.Entity;
at the beginning of your controller class file to be able to call them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With