vs2012 mvc3项目ObjectContext与DBContext .




We move some projects from VS2010 to VS2012 but still using .NET 4.0 and not .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.

Second point the version 5.0, inherit from DbContext and not ObjectContext like version 4.x. With the version 5.0 I don't see any way to pass the connection string as parameter.

How can I use version 4.x in VS2012, with the same EDMX designer behavior ?



As mentioned in the comments, you're really getting EF 4.4, not EF 5.0. However, confusingly, EF 4.4 in contained in the NuGet EntityFramework 5.0 package.

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. Now you'll have yourObjectContext again, and if you wish, you can remove the EntityFramework package from your project.

I'm not sure if there's any way to change this default behaviour of adding the NuGet package.


《vs2012 mvc3项目ObjectContext与DBContext .》常伟华 创作。
采用 知识共享 署名-相同方式共享 3.0 中国大陆 许可协议进行许可。
  • 多说评论
  • 签名
  • 新浪微博
  • 默认评论
  • Tab Header 5

0 条评论 / 点击此处发表评论

Tab Content 5



sitemap     156.99ms