问题: 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 ? 从老外的问题中可以看出,使用DBContext时,需要替换连接字符串还是个问题呀,下面看看解决的办法吧:
解决办法: 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.