简体   繁体   English

在VS2012中使用EF 4.4而不是5.0

[英]Using EF 4.4 and not 5.0 with VS2012

We move some projects from VS2010 to VS2012 but still using .NET 4.0 and not .NET 4.5 我们将一些项目从VS2010迁移到VS2012但仍然使用.NET 4.0而不是 .NET 4.5

When I add an new EDMX, VS2012 use EF 5.0 but I'd like continue to use the version 4.x it's the first point. 当我添加一个新的EDMX时,VS2012使用EF 5.0,但我想继续使用版本4.x这是第一点。

Second point the version 5.0, inherit from DbContext and not ObjectContext like version 4.x. 第二点版本5.0,继承自DbContext而不是版本4.x的ObjectContext。 With the version 5.0 I don't see any way to pass the connection string as parameter. 使用5.0版本,我没有看到任何方法将连接字符串作为参数传递。

How can I use version 4.x in VS2012, with the same EDMX designer behavior ? 如何在VS2012中使用版本4.x,具有相同的EDMX设计器行为?

Thanks, 谢谢,

As mentioned in the comments, you're really getting EF 4.4, not EF 5.0. 正如评论中所提到的,你真的得到了EF 4.4,而不是EF 5.0。 However, confusingly, EF 4.4 in contained in the NuGet EntityFramework 5.0 package. 然而,令人困惑的是,EF 4.4包含在NuGet EntityFramework 5.0包中。

For your other question, you can open the EDMX in the designer, restore "Code generation strategy" from "None" to "Default", then in the solution explorer, remove the .tt files. 对于您的其他问题,您可以在设计器中打开EDMX,将“代码生成策略”从“无”恢复为“默认”,然后在解决方案资源管理器中删除.tt文件。 Now you'll have your ObjectContext again, and if you wish, you can remove the EntityFramework package from your project. 现在,您将再次拥有ObjectContext ,如果愿意,可以从项目中删除EntityFramework包。

I'm not sure if there's any way to change this default behaviour of adding the NuGet package. 我不确定是否有任何方法可以更改添加NuGet包的默认行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM