配置:
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
答案 0 :(得分:0)
您是否尝试过从web.config中删除上面显示的代码?你有任何错误吗?
代码中的注释链接(EF 4.3)说配置部分是可选的。同样在EF 5 RC页面上:http://blogs.msdn.com/b/adonet/archive/2012/05/15/ef5-release-candidate-available-on-nuget.aspx代码优先演练链接到EF 4.2,所以它可能仍然有效。
答案 1 :(得分:0)
您可以直接使用连接字符串
var db = new DbContext("Data Source=serverName;Initial Catalog=dbName;Integrated Security=True;MultipleActiveResultSets=True");
//instead of
var db = new DbContext("Name=DBConnectionConfigEntryName");