# Thursday, 04 October 2012

Moving an MVC4 Visual Studio 2010 project to 2012 is so far in my experience with a small application rather quick and easy. However, if that’s all you do then your app will be missing out on the nice .Net 4.5 and Entity Framework 5 features. 

Upgrading these two items, while not terribly difficult, does have a few challenges to overcome even for my relatively small application with two projects and about a dozen NuGet packages.

Hopefully my experience will help the next person get through their upgrade faster.

MVC 3 or MVC4 Release Candidate?

If you are on MVC3 or say the MVC4 Release candidate take a look at these extra steps to take.

MVC4 & VS 2010 to 2012 Steps

Open your VS 2010 solution in 2012 and let it convert your solution.

And done… Well almost.

If you happen to be using dependencies / nuget packages, there may be a chance that these are using older frameworks.  If you were already using MVC4 in 2010 chances are then you already figured out how to direct these packages to use newer versions of their dependencies using binding redirects. 

For example MVCContrib.TestHelpers references the MVC3 runtime.  My VS10 project was already using a binding redirect so all should be good. 

I am also using the MiniProfiler and in my MVC4, 2010 project I upgraded to the Entity Framework 4.4 Prerelease.  When I did this I had to add a binding redirect since the MiniProfiler at the time was using an earlier release.

If you are having issues, you’ll have to investigate if you have a dependency using an older version of a DLL that you can use a redirect to solve.


In my case, my VS12 project with the TestHelpers stopped working even with the redirect.  I tried on my PC/laptop as well new and upgraded projects.  I can only assume it must be something wierd on my boxes.  I have been using the betas, previews and RC versions of MVC on both boxes so it just might be something related. 

The binding redirect *should* work.  However, if you run into my case, the atomic option is to download the MVCContrib source, change the reference for the TestHelpers project to use the MVC4 runtime, recompile and use the new DLL in your project.  This is what I ended up doing.

Done. If that’s all you want to do.

Upgrade Project(s) to 4.5

Right Click on each project and select properties.  Change the Target Framework to 4.5 in the Application section.

Update all packages to target 4.5

Perform a search and replace for the entire solution to replace targetframework=”net40” to targetframework=”net45”.  This will update all of your packages.config to use 4.5 targeted packages instead of 4.0.


Open your web.config and change your targetFramework=”4.0” to 4.5.  This informs IIS to also target 4.5 now.

Upgrade EF 4.4 to EF 5

Uninstall the EF package, and reinstall it via Nuget. I recommend doing this from the console/command line instead of the package GUI.  At the command line you can force an uninstall just in case you have other packages that require EF.  I originally uninstalled/reinstalled via the GUI and first removed all of my dependent projects and then added them all back in but I ran into problems with my dependent projects having issues.  I found it easier to force EF first, make sure it was all working and then investigate my other dependent packages one at a time.

You can open the console from the Tools Menu, Library Package Manager and Package Manager Console


or by typing console and hitting enter in the Quick Launch which is in the upper right hand corner of VS 2012.


The console opens in the lower middle of VS 2012 and allows you to type in nuget commands.


Type in

uninstall-package EntityFramework –Force

and then

install-package EntityFramework

Be sure to do this for all projects using Entity Framework.  You can change this by selecting the project from the dropdrown list in the console.

If all of the above was done correctly it will install version 5.0.  If it still says 4.4 something is still pointing to the 4.0 framework.


Build your solution.

If you get an error about the CompareAttribute being ambiguous reference…


Fix by Adding System.Web.Mvc. to the Compare Attribute.





Rebuild.  Congratulations.  You now have a VS 2012 MVC4 project using .Net 4.5 and EF 5.

Now for the rest

From here you should now investigate all of your Nuget Packages or external references.  Since we are now pointing to 4.5 it may be that a newer version is available.  Nuget doesn’t handle updating to the new targeted version at this point.  You’ll have to look at each package and if you know it has a newer one for 4.5 you’ll want to look at uninstalling it and reinstalling as we did earlier.

One Quick way to reinstall all the packages

You could delete all of your packages and their folders and set Nuget to restore packages.



Now the next time you recompile, Nuget will get all of the new stuff.

However, this could wreak havoc on your project.  I opted for handling my dependencies one at a time so I could deal with issues for each package one at a time. 

Happy Coding! Smile

Posted 10.04.2012  #    Comments [1]  | 
# Friday, 25 February 2011

Visual Studio 2010 or Visual Web Developer Express 2010 or Visual Phone Developer Express 2010 that matches the language version of Silverlight Tools 4 must be installed before installation of Silverlight Tools can continue.

I was running into the above error when I tried to install Silverlight 4 Tools for Visual Studio 2010 whether I did it from the downloaded install or via the Web Platform Installer.

Downloaded Silverlight4_Tools.exe error message:




If you open the first log file you will find the error at the bottom:

Installation Blockers:
    1) Visual Studio 2010 or Visual Web Developer Express 2010 or Visual Phone Developer Express 2010 that matches the language version of Silverlight Tools 4 must be installed before installation of Silverlight Tools can continue.  Silverlight Tools is available in other languages at <A HREF="http://go.microsoft.com/fwlink/?LinkId=177432">http://go.microsoft.com/fwlink/?LinkId=177432</A>.

When I looked online for this error I was only seeing references to the Beta and Release Candidates of Visual Studio 2010.

After a little thought, I decided to open up the readme file for the SP1 Beta of Visual Studio 2010 that I installed a while back and there was the answer:

2.1.4. Error when you try to install Silverlight 4 Tools for Visual Studio 2010 on Visual Studio 2010 SP1 Beta

An error message may appear when you try to install Silverlight 4 Tools for Visual Studio 2010 on Visual Studio 2010 SP1 Beta. 

To resolve this issue:

Because Silverlight 4 Tools for Visual Studio 2010 (http://www.microsoft.com/downloads/en/details.aspx?FamilyID=b3deb194-ca86-4fb6-a716-b67c2604a139&displayLang=en) is included in Visual Studio 2010 SP1 Beta, you do not have to install Silverlight 4 tools separately.  Also, you do not have to uninstall Silverlight 4 Tools for Visual Studio 2010 before you install Visual Studio SP1 Beta.

There you have it.  If you installed VS 2010 SP1 Beta then you already have the Silverlight 4 Tools.  How’s that for a descriptive error message. :-)

Happy Coding!

Posted 02.25.2011  #    Comments [6]  | 
# Thursday, 30 September 2010

New to Visual Studio 2010?  Did you just install it like me?  Are you still using Visual SourceSafe even though you don’t want to admit it?  It’s OK, I am too.

Are you getting an Unable to Access Database error when you want to fire up an existing project in VSS?


VS 2010 defaults to connecting to Team Foundation Server.  To change this go to the Tools menu and select Options.

Check off the select all settings and expand the Source Control tree item.  Change the current source control plug-in to Visual SourceSafe.  It should be happy sailing from here.


Now hurry up and replace VSS since it’s coming to end of life mid year 2011 (*slapping self*).

Slapping Self



There are after all many better alternatives out there.

Happy Coding!

Posted 09.30.2010  #    Comments [0]  |