[英]How to properly change target framework to .NET 4.0
I built an application with target framework .NET 4.6 using MVC 5 and Entity Framework 6 using Visual Studio 2017 on my Windows 7 machine. 我在Windows 7计算机上使用Visual Studio 2017使用MVC 5和Entity Framework 6构建了具有目标框架.NET 4.6的应用程序。 I'm now being told that I should have built the application to target .NET 4.0 because the production environment only has 4.0 installed. 现在,我被告知我应该以.NET 4.0为目标构建该应用程序,因为生产环境仅安装了4.0。 So I changed the target framework to 4.0 but now the application will not build on my machine. 因此,我将目标框架更改为4.0,但现在该应用程序将无法在我的计算机上构建。
I'm guessing I also need to downgrade MVC and EF. 我猜我还需要降级MVC和EF。 How is the proper way of doing this? 如何做到这一点的正确方法?
And which versions of MVC and EF should I install? 我应该安装哪个版本的MVC和EF?
Do I need to make any manual changes to web.config? 我是否需要对web.config进行任何手动更改?
There is no "proper" way, you have 3 options, in my favorite order: 没有“适当”的方式,您有3个选项,以我最喜欢的顺序排列:
update-packages
command helps, but be sure to backup your project first. 也许update-packages
命令会有所帮助,但是请务必先备份您的项目。 Some packages become obsolete after time, some are renamed. 有些软件包会在一段时间后过时,有些会被重命名。 This is what will cause issues. 这将导致问题。 Also, some of the Methods/API calls will be different, so some rework will be needed. 此外,某些方法/ API调用将有所不同,因此需要进行一些重做。 As for the rest of your questions: 至于其余的问题:
I'm guessing I also need to downgrade MVC and EF. 我猜我还需要降级MVC和EF。 How is the proper way of doing this? 如何做到这一点的正确方法?
Use the nuget package manager
And which versions of MVC and EF should I install? 我应该安装哪个版本的MVC和EF?
The nuget package manager will fix this for you.
Do I need to make any manual changes to web.config? 我是否需要对web.config进行任何手动更改?
Sometimes: yes.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.