不能在我的asp.net mvc4 +实体框架5中引用ToListAsync()

时间:2015-09-04 16:10:38

标签: asp.net-mvc entity-framework asp.net-mvc-4 entity-framework-5

我正在开发一个asp.net mvc4 web应用程序+实体框架5.我试图引用ToListAsync()如下: -

var tservers = await t.TServers.Include(a => a.Technology.TechnologyIPs).Include(a => a.TVirtualMachines.Select(a2 => a2.Technology))
                   .Where(
           a2 => (!singlescan && String.IsNullOrEmpty(FQDN) && a2.TechnologyRole.Name.ToLower() == "hypervisor")
                 ||
                 (singlescan && !String.IsNullOrEmpty(FQDN) && a2.Technology.IT360ID == it360id)
                   ).ToListAsync();

但我一直收到以下错误: -

Error   10  'System.Linq.IQueryable<**.Models.**>' does not contain a definition for 'ToListAsync' and no extension method 'ToListAsync' accepting a first argument of type 'System.Linq.IQueryable<**.Models.***>' could be found (are you missing a using directive or an assembly reference?)    C****\Repository.cs 181 22   Scanning

我将这些引用包含在我的课程中:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using System.Data;
using System.Data.Objects.SqlClient;
using System.Data.Entity.Infrastructure;
using T.ViewModels;
using System.DirectoryServices.AccountManagement;
using System.Security.Principal;
using System.DirectoryServices;
using System.Linq.Expressions;
using System.Data.Objects;
using System.Linq.Dynamic;
using System.Configuration;
using System.Threading.Tasks;

究竟是什么问题? ToListAsync()在EF 5中可用吗?

1 个答案:

答案 0 :(得分:2)

没有。不是。它被添加到EF6中。