找不到类型'System.Data.Entity.Infrastructure.SqlConnectionFactory'的构造函数

Leo*_*ens 4 asp.net-mvc entity-framework windows-8 entity-framework-5 visual-studio-2012

昨天我将我的电脑从Windows 7"升级"到Windows 8,所以现在我正在使用Visual Studio 2012,并打开我的Visual Studio 2010项目.

这个项目总是工作正常,但它在Visual Studio 2012中不起作用.我有一些奇怪的错误,但我修复了这些.现在我留下了一个我无法修复但在Google上找不到的错误:

我得到这个例外:

无法将Database.DefaultConnectionFactory设置为应用程序配置中指定的'System.Data.Entity.Infrastructure.SqlConnectionFactory,EntityFramework'类型的实例.请参阅内部异常了解详细信

具有以下不足之处:

找不到类型'System.Data.Entity.Infrastructure.SqlConnectionFactory'的构造函数.

我的Web.Config看起来非常标准:

  <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnet-WebUI-201253192737;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>

  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="Data Source=.\SQLEXPRESS; Integrated Security=True; MultipleActiveResultSets=True" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
Run Code Online (Sandbox Code Playgroud)

SqlConnectionFactory类存在,它有2个构造函数(一个无参数,一个接受连接字符串).我通过在C#代码中创建一个SqlConnectionFactory来测试它.

我已经删除了Entity Framework并重新安装了它,但这并没有解决问题.

我正在使用实体框架5.0 RC(在VS2010中如前所述)在SQL Server 2012 + Tools和IIS express中使用.

Leo*_*ens 9

我解决了这个问题.我改变了这个:

  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="Data Source=.\SQLEXPRESS; Integrated Security=True; MultipleActiveResultSets=True" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
Run Code Online (Sandbox Code Playgroud)

至:

  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>
Run Code Online (Sandbox Code Playgroud)

现在它有效.虽然有点愚蠢,但我想提供连接字符串作为参数.

我通过在VS 2012中使用实体框架创建一个新的MVC 4项目并比较Web.Config文件来找到它.我注意到另一个区别.

我的实体框架程序集版本为4.4.0.0(尽管我从NuGet安装了5.0 RC).我创建的新项目具有版本5.0.0.0的程序集.有谁能解释一下?