Upgrading an ASP.NET MVC 2 Project to ASP.NET MVC 3

Resources:
ASP.NET MVC 3 Preview 1 – MVC-3-Preview-1-Release-Notes.doc
ASP.NET MVC Preview 3 Release – ScottGu
ASP.NET MVC 3 Preview 1 Released : Channel 9 Video and Hanselminutes Podcast 224, Oh My!
ASP.NET MVC 3 Preview 1 Released – Phil Haack

ASP.NET MVC 3 can be installed side by side with ASP.NET MVC 2 on the same computer, which gives you flexibility in choosing when to upgrade an ASP.NET MVC 2 application to ASP.NET MVC 3.

The simplest way to upgrade is to create a new ASP.NET MVC 3 project and copy all the views, controllers, code, and content files from the existing MVC 2 project to the new project and then to update the assembly references in the new project to match the old project. If you have made changes to the Web.config file in the MVC 2 project, you must also merge those changes with the Web.config file in the MVC 3 project.

To manually upgrade an existing ASP.NET MVC 2 application to version 3, do the following:

  1. In both Web.config files in the MVC 3 project, globally search and replace the MVC version. Find the following:
  2. System.Web.Mvc, Version=2.0.0.0
    

    Replace it with the following

    System.Web.Mvc, Version=3.0.0.0
    

    There are three changes in the root Web.config and four in the ViewsWeb.config file.

  3. In Solution Explorer, delete the reference to System.Web.Mvc (which points to the version 2 DLL). Then add a reference to System.Web.Mvc (v3.0.0.0).
  4. In Solution Explorer, right-click the project name and then select Unload Project. Then right-click again and select Edit ProjectName.csproj.
  5. Locate the ProjectTypeGuids element and replace {F85E285D-A4E0-4152-9332-AB1D724D3325} with {E53F8FEA-EAE0-44A6-8774-FFD645390401}.
  6. Save the changes and then right-click the project and select Reload Project.
  7. If the project references any third-party libraries that are compiled using ASP.NET MVC 2, add the following highlighted bindingRedirect element to the Web.config file in the application root under the configuration section:
<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="System.Web.Mvc"
          publicKeyToken="31bf3856ad364e35"/>
      <bindingRedirect oldVersion="2.0.0.0" newVersion="3.0.0.0"/>
    </dependentAssembly>
  </assemblyBinding>
</runtime>

8 Responses to Upgrading an ASP.NET MVC 2 Project to ASP.NET MVC 3

  1. Pingback: Tweets that mention » Upgrading an ASP.NET MVC 2 Project to ASP.NET MVC 3 Rick Schott – devlpr.net -- Topsy.com

  2. Pingback: » Upgrading an ASP.NET MVC 2 Project to ASP.NET MVC 3 Rick Schott … - asp

  3. Pingback: ASP.NET MVC 3, IIS Express, VS2010 SP1 Beta & SQL CE 4 – They’ve all arrived!!! « ASP.NET, MVC & SQL Server Development

  4. Pingback: Why I upgraded to Entity Framework 4?

  5. I found that in order for the System.Web.Mvc 3.0.0.0 assembly to be listed in the Add References dialog, I had to target .NET Framework 4.0 for my web project.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">