Some (official or not) upgrade Mvc3 to Mvc5 guide?

后端 未结 2 570
温柔的废话
温柔的废话 2020-12-13 06:46

There is a (non-Microsoft) NuGet package that allows upgrading the Mvc3 to Mvc4.

There is a (Microsoft) article that explains how to manually migrate from Mvc3 to Mv

2条回答
  •  攒了一身酷
    2020-12-13 07:21

    Due to the installation of VS2015 I had to convert my applications from MVC3 on MVC5. I've done this with success :). I hope that the following description will help someone in a similar issue:

    1) Change .Net Framework to 4.5

    Project -> Properties -> Application -> Target Framework -> 4.5
    

    2) Install from Package Manager Console:

    Install-Package Microsoft.AspNet.Mvc -Version 5.2.3
    

    3) There is a line in web.config that is:

    
    

    Changed it to the version of system.web.webpages.dll in your bin folder:

    
    

    4) If your project uses the EntityFramework you have to upgrade it to version 5.x or higher and set dll references to

    ....\net45\EntityFramework.dll
    ....\net45\EntityFramework.SqlServer.dll
    

    5) To solve problems like:

    Error   CS0104  'Compare' is an ambiguous reference between 'System.ComponentModel.DataAnnotations.CompareAttribute' and 'System.Web.Mvc.CompareAttribute'
    

    you can add:

    using CompareAttribute = System.Web.Mvc.CompareAttribute;
    

    6) You will probably have to change additional definitions in the web.config and the Views\web.config and find and replace text as shown below:

    System.Web.Mvc, System.Web.Mvc.*, System.Web.Razor, System.Web.WebPages.Razor change from 3.0.0.0 to 5.0.0.0

    System.Web.WebPages, System.Web.WebPages.* change from 1.0.0.0 to 3.0.0.0

    That's all :)

提交回复
热议问题