26

I'm aware of manual guides to upgrade from 3 to 4 like this one: http://www.dotnetexpertguide.com/2011/12/upgrade-aspnet-mvc-3-project-to-mvc-4.html

The guides vary in their details which clearly signals danger. Is there a tool that handles the transition from an MVC3 project to MVC4? This would implicitly mean migrating from .Net 4 to .Net 4.5, which does have some significant implications in terms of all the namespace redirects Microsoft added between the 2 versions.

I'm also aware of manual guides that basically say to give up on upgrading and instead just create a new project and port things over piece by piece into the new project. This has a lot of obvious opportunities for small mistakes to create big problems.

So, a tool that's been tested I can count on to not make a silly mistake like I might would really help here. Does that exist? There's a tool to get from MVC2 to 3, so not finding one for 3 to 4 surprised me.

Background for why I'd like to upgrade: we have several newer projects on .Net 4.5 MVC4, and an important older project on .Net 4 MVC3 (with some .Net 2 and MVC 2 mixed in...), and the more our shared libraries move forward the more that old project struggles. We can freeze the last working on the shared libraries obviously, or fork them and maintain 2 versions... obviously neither of these is very appealing. I'd prefer to just update the toolset on the older project and bring everything into parity.

Chris Moschini
  • 36,764
  • 19
  • 160
  • 190
  • 3
    No tool, but also check my write-up after migrating from 4.0 / MVC 3 to 4.5 / MVC 4 - http://ivanz.com/2012/08/20/guide-for-migrating-an-asp-net-mvc-solution-to-net-4-5-and-asp-net-mvc-4/ – Ivan Zlatev Sep 29 '12 at 20:43
  • Thanks that did the trick. So to clarify, I had to change my Target Framework on all Projects to .Net 4.5, then uninstall Entity Framework, then install it again, then finally upgrade MVC 3 to 4 as described in the link I included. That did the trick. At last: Dictionaries in JSON serializing over POST. – Chris Moschini Dec 29 '12 at 01:34
  • Reported the bug - https://github.com/NandipMakwana/UpgradeMvc3ToMvc4/issues/1 – Chris Moschini Feb 20 '13 at 08:12

1 Answers1

37

An auto-upgrade now exists.

Check this out: http://www.dotnetexpertguide.com/2013/02/aspnet-mvc-auto-upgrade-mvc-3-to-mvc-4-application.html

It is a Nuget Package called UpgradeMvc3ToMvc4

mezoid
  • 28,090
  • 37
  • 107
  • 148
joerage
  • 4,863
  • 4
  • 38
  • 48
  • Pretty cool - did you write this? It does some odd things - for example it adds controlRenderingCompatibilityVersion="4.0" to the pages tag in Web.Config, which seems unnecessary and potentially a problem in the future. However it does work, and saved me a bunch of time - thank you. – Chris Moschini Feb 16 '13 at 23:03
  • @ChrisMoschini - No, I am not the author, but i am glad you found it useful! – joerage Feb 18 '13 at 19:47
  • @IvanZlatev If you mean in the .csproj file, no, these aren't changed (but don't need to change) - which GUIDs are you referring to? – Chris Moschini Feb 18 '13 at 21:13
  • @ChrisMoschini Doesn't the ASP.NET MVC 4 project require an updated Project GUID for it to be picked up as an MVC 4 project (rather than MVC 3) by the IDE for the purpose of templates (file/items) and others? `{E53F8FEA-EAE0-44A6-8774-FFD645390401}` to `{E3E379DF-F4C6-4180-9B81-6769533ABE47}`. – Ivan Zlatev Feb 19 '13 at 16:56
  • @IvanZlatev Good eye! It does not do this, and that is indeed a bug of this NuGet package - the MVC3 project I upgraded with this tool still expects to add MVC3 Layouts, not MVC4 Layouts (though the distinction is very minor). – Chris Moschini Feb 19 '13 at 23:58
  • @IvanZlatev & ChrisMoschini : It is working fine for me. I think in post there is something mentioned similar. Please have a look at it. "Visual Studio will ask to reload project as we are changing project type from MVC 3 to MVC 4." I believe it is mentioned about project GUID only. – mcacorner Feb 20 '13 at 11:37
  • Doesn't appear to exist any more – nathanchere Oct 23 '14 at 10:18
  • Could you please do a V3 to V5 upgrade too :) – Peter Morris Dec 10 '15 at 11:44