Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2 Beta (updated!)

NOTE: There is an updated version of this tool that is compatible with ASP.NET MVC 2 RTM. 

Thanks to the great feedback I’ve received on my ASP.NET MVC conversion tool for ASP.NET MVC 2 Preview 2 I’ve updated it to support conversions to ASP.NET MVC 2 Beta. I’ve included a number of bugs fixes and improvements based on the feedback:

  1. The JavaScript files have been updated to be compatible with ASP.NET MVC 2 Beta
  2. A “Scripts” folder will be automatically created if one does not already exist
  3. References to the System.Web.Mvc.dll assembly will be updated to use the fully-qualified name (public key token, etc.)
  4. UI improvements

ASP.NET MVC Solution Converter

Download

The app is a single executable: Download MvcAppConverter.zip (226 KB).

Usage

The only requirement for this tool is that you have .NET Framework 3.5 SP1 on the machine. You do not need to have Visual Studio or ASP.NET MVC installed (unless you want to open your project!). Even though the tool performs an automatic backup of your solution it is recommended that you perform a manual backup of the solution as well.

  • To convert an ASP.NET MVC 1.0 project built with Visual Studio 2008 to an ASP.NET MVC 2 project in Visual Studio 2008 perform these steps:
    • Launch the converter
    • Select the solution
    • Click the “Convert” button
  • To convert an ASP.NET MVC 1.0 project built with Visual Studio 2008 to an ASP.NET MVC 2 project in Visual Studio 2010:
    • Perform the above steps, then open the project in Visual Studio 2010 and it will perform the remaining conversion steps

What it can do

  • Open up ASP.NET MVC 1.0 projects from Visual Studio 2008 (no other versions of ASP.NET MVC or Visual Studio are supported)
  • Create a full backup of your solution’s folder
  • For every VB or C# project that has a reference to System.Web.Mvc.dll it will (this includes ASP.NET MVC web application projects as well as ASP.NET MVC test projects):
    • Update references to ASP.NET MVC 2
    • Add a reference to System.ComponentModel.DataAnnotations 3.5 (if not already present)
  • For every VB or C# ASP.NET MVC Web Application it will:
    • Change the project type to an ASP.NET MVC 2 project
    • Update the root ~/web.config references to ASP.NET MVC 2
    • Update the root ~/web.config to have a binding redirect from ASP.NET MVC 1.0 to ASP.NET MVC 2
    • Update the ~/Views/web.config references to ASP.NET MVC 2
    • Add or update the JavaScript files (add jQuery, add jQuery.Validate, add Microsoft AJAX, add/update Microsoft MVC AJAX, add Microsoft MVC Validation adapter)
  • Unknown project types or project types that have nothing to do with ASP.NET MVC will not be updated

What it can’t do

  • It cannot convert projects directly to Visual Studio 2010 or to .NET Framework 4.
  • It can have issues if your solution contains projects that are not located under the solution directory.
  • If you are using a source control system it might have problems overwriting files. It is recommended that before converting you check out all files from the source control system.
  • It cannot change code in the application that might need to be changed due to breaking changes between ASP.NET MVC 1.0 and ASP.NET MVC 2. Consult the readme for information on breaking changes.

Feedback, Please!

If you need to convert a project to ASP.NET MVC 2 please try out this application and hopefully you’re good to go. If you spot any bugs or features that don’t work leave a comment here and I will try to address these issues in an updated release.

7 Comments

  • This is a great tool! Will there be a new version to support the RC soon? Keep up the good work. :)

  • Nice tool. I appreciate the effort to write it and to publish it.

  • Andrew - I'm glad the tool helped you!
    I wonder if the issue you have is because you're referencing a copy of System.Web.Mvc.dll instead of the default installed one? The tool might be getting confused about whether it's really an MVC project or not. When you run the tool it should list what it "thinks" your project is and what it "plans" to do. Did it appear to recognize the projects as being MVC 1.0 Web Applications?
    If not then we can investigate further. We're planning to integrate this conversion functionality into Visual Studio 2010 so we want to make sure that we get the detection logic right!
    Thanks,
    Eilon

  • Thanks, just used this on a project and it works fine.

    One more file you might want to move over is MicrosoftMVCValidation.js. I just created a new mvc2 project and copied it over from there.

  • Thanks!! It worked like a charm converting my VS2008 MVC 1 project to a VS2010 MVC 2 project. I tried a few other tools (including the one that came with VS2010) and yours was the first that worked.

  • Great tool. Would be nice to have a checkbox so I decide whether or not to backup the project.

  • Hi Eilon, Thanks for this great tool, it's a real shame VS2010 isn't supporting MVC 1 applications. 've now successfully converted 3 fairly large MVC 1.0 applications to MVC 2 RC2 without any problems using your tool :) It would be cool to get this integrated into a visual studio add-in or wizard of some description to simplify the process. Also maybe you should update the post to let people know that it works with MVC 2 RC2 and not just the beta.

Comments have been disabled for this content.