Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

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

To help our customers adopt ASP.NET MVC 2 I built an application that helps upgrade Visual Studio 2008 solutions that use ASP.NET MVC 1.0 to use ASP.NET MVC 2 Preview 2. This application is inspired by Scott Hanselman’s blog post on updating ASP.NET MVC projects to work in Visual Studio 2010 Beta 1.

image

Download

The app is a single executable: Download MvcAppConverter.zip (220 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.

Published Monday, October 19, 2009 12:38 PM by Eilon
Filed under: , ,

Comments

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Monday, October 19, 2009 4:50 PM by Chris Hardy (ChrisNTR)

Since Preview 2 is, as it implies, is a preview, I guess we'll continue to stick to using ASP.NET MVC 1 for production sites and purely use the converter to play around with ASP.NET MVC Preview 2 for the time being until a RC/RTM is out?

Nice work, looks like a handy tool!

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Tuesday, October 20, 2009 4:59 PM by Gene

I tried a to do the migration (a large site from MVC 1.0 to 2.0 and from VS 2008 to VS 2010) myself, with disastrous results. I figured I was looking at spending a couple days fiddling with settings to get everything working again.

Your tool had it up and running in 5 minutes. No issues that I have found so far. Thank you so much!

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Tuesday, October 20, 2009 7:16 PM by Karl

Any chance on getting source code. This doesn't work as is for me. Its failing when looking for specific javascript files...I'm not crazy enough to use the default MVC structure, or leave in all the gunk js the default project uses.

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Wednesday, October 21, 2009 11:34 PM by Donn Felker

Does this converter rely on project type guids? Reason I ask is because all of my MVC Projects do not contain the MVC project type guid (so users can download them from my blog after a presentation and not have to have MVC installed - I include the binaries in my d/l's).

Thanks!

Donn

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Thursday, October 22, 2009 7:23 AM by sorin

I get this error

Converting between two versions of Visual Studio is not supported

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Thursday, October 22, 2009 8:27 PM by I know my question is off subject

where can i find or is there a tool to generate standard CRUD method with LINQ TO SQL?

I dont want to reinvented the wheel!

Thanks..

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Friday, October 23, 2009 5:33 PM by Jerrie Pelser

Great tool, thanks so much!

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Tuesday, October 27, 2009 11:23 AM by David Kujawski

Can you provide source code for this tool?  The tool doesn't work for our MVC v1 project because we have a spcialized folder structure (and the tool can't find some files).

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Tuesday, November 10, 2009 12:59 PM by goodbyeforms

Beautiful.  Thanks much.  And for those using Castle IoC, this signature has changed:

protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Saturday, November 14, 2009 9:37 AM by Raj

Event after using the tool, I am not able to open the project. Visual Studio says "The project type is not supported by this installation".

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Sunday, November 15, 2009 4:57 PM by irobinson

This worked quite well for me on a project that was started from the CodeBetter Canvas project.

Although, it did fail until I added a "Scripts" folder in the "Web" project - so that it could add all of the JavaScript files to it.

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Monday, November 16, 2009 12:38 PM by matthewreily

Worked great for me!  Thank you

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Thursday, November 19, 2009 7:33 PM by Eilon

Karl

>>>>>>>>>> Any chance on getting source code. This doesn't work as is for me. Its failing when looking for specific javascript files...I'm not crazy enough to use the default MVC structure, or leave in all the gunk js the default project uses.

I am fixing this bug in the tool and will re-release it with support for ASP.NET MVC 2 Beta. I will see if I can get the source code published as well. We do plan to integrate most of this functionality into Visual Studio 2010 as well.

Thanks,

Eilon

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Thursday, November 19, 2009 7:36 PM by Eilon

Donn Felker

>>>>>>>>>> Does this converter rely on project type guids? Reason I ask is because all of my MVC Projects do not contain the MVC project type guid (so users can download them from my blog after a presentation and not have to have MVC installed - I include the binaries in my d/l's).

Hi Donn,

The converter relies on the project type GUID for certain parts of the functionality. Some features require that you use the MVC project type GUID, such as to decide whether to add the updated JavaScript files. Other features check whether the project is any kind of class library in order to update references of System.Web.Mvc.dll from 1.0.0.0 to 2.0.0.0. This is to support the scenario where you have a class library project that contains helpers or controllers that you want to convert.

A workaround is to temporarily add the project type GUID (which should be {603c0e0b-db56-11dc-be95-000d561079b0}), run the converter, and then remove the GUID (which will then be {f85e285d-a4e0-4152-9332-ab1d724d3325}).

Thanks,

Eilon

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Thursday, November 19, 2009 7:37 PM by Eilon

sorin

>>>>>>>> I get this error

>>>>>>>> Converting between two versions of Visual Studio is not supported

Hi sorin,

That error can occur if you try to convert a project that was build with Visual Studio 2010. Right now this tool only supports projects built with Visual Studio 2008.

Thanks,

Eilon

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Wednesday, November 25, 2009 8:36 PM by mike o'neill

Your tool works well but you should set the reference to System.Web.Mvc to copy local= true. You need this if you want to deploy a mvc 2 project to Azure.

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Thursday, December 3, 2009 11:48 AM by Eric Bowen

Worked great for me!  Thanks!

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Wednesday, January 27, 2010 8:29 AM by Brian

Worked like a charm, awesome!!

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Saturday, March 13, 2010 5:56 PM by rkgallegos

Worked like a charm! Getting ready to head to MIX10 and I had done ND in VS 2008/MVC and then today I downloaded MVC2 and my solution wouldn't open. Downloaded the converter, ran it on the solution, and I'm good to go. Thank you so much!

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Thursday, March 18, 2010 9:23 AM by James Crowley

Upgrade to MVC 2.0 with care if you're using the AntiForgeryToken... you'll kick all your visitors off the site.

weblogs.asp.net/.../beware-upgrade-to-asp-net-mvc-2-0-with-care-if-you-use-antiforgerytoken.aspx

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Tuesday, March 30, 2010 12:44 PM by José López

I upgrade to mvc 2.0 but i couldn't do work the next line from some script

userName: {

required: true,

minlength: 5,

remote: '<%= Url.Action( "IsUsernameAvailable", "User") %>'

},

I used this line to verified the user name but i can't use the validator beacose when when i put this code the submit button not generate the post, I'm working with json,jquery and mvc2

Any idea?

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Tuesday, March 30, 2010 5:03 PM by Eilon

Jose

>>>>>>>> I upgrade to mvc 2.0 but i couldn't do work the next line from some script

If looks like you're trying to do a remote validator. It's hard to tell exactly where the problem is from just that code. If you want a complete sample of how to do a remote validator you can check out Brad Wilson's blog (he's a developer on the ASP.NET MVC team):

bradwilson.typepad.com/.../remote-validation-with-aspnet-mvc-2.html

Thanks,

Eilon

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Friday, April 2, 2010 4:53 PM by Jim Maguire

Saved a lot of time.  Thanks!

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Monday, June 21, 2010 4:52 AM by Benjie Buluran

your tool rocks!!!

fixed my problem instantly!

great thanks!

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Wednesday, June 30, 2010 5:31 PM by frenzy

I get the following error:

csproj has an unknown type and will not be converted.  

the reason i'm using this is because visual studio 2010 gives me conversion errors about csproj, on every project i have from visual studio 2008.

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Thursday, July 1, 2010 4:50 PM by Eilon

@frenzy

Can you show me what the error is during the Visual Studio conversion?

If you can send me a simplified version of your project that has the conversion problem to "elipton -AT- microsoft.com" I can investigate what the problem is.

Thanks,

Eilon

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Tuesday, August 10, 2010 6:49 AM by jatin_kacha

Hi,

Its nice share. I have successfully converted my application from MVC 1 to MVC 2.

Jatin Kacha - Dhanashree Inc

B.Sc(IT), MCTS

.Net & SQL Server Tech. Leader

Blog : jatinkacha.wordpress.com

LinkedIn : in.linkedin.com/.../jatinkacha

Company: http://www.dhanashree.com

# re: Migrating ASP.NET MVC 1.0 applications to ASP.NET MVC 2

Wednesday, November 14, 2012 11:54 PM by Siva Prasad

   Once i upgrade to MVC 2.0 UNABLE TO CREATE VIEW. And also right+click on the folder select new item, from the Web option can not see mvc.

If having any solution for these issues please update.