Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.1.1
Decided it wasn’t worth it trying to figure out these nightmarish dependencies. I restored a backup of the Project and from the Package Manager Console (PMC) manually updated MVC and EntityFramework with older versions that didn’t call in the Razor 3.1.1 dependency.
Install-Package Microsoft.AspNet.Mvc -Version 5.0.0
Install-Package entityframework -Version 6.0.0
Note: If you use the DbContext.EntityState method it has been moved from System.Data to System.Data.Entity, update your usings as appropriate.
If you have Simple membership you will need to install Microsoft.AspNet.WebPages.WebData (see Is ASP.NET MVC 5 incompatible with the WebMatrix SimpleMembershipProvider? ) and if you have OAuth in the Project (The MVC4 template installs OAuth into the project, I wasn’t using it so I was able to remove it. If you are using it you have more work cut out for you) you’ll have to Uninstall OAUTH (WebData had a dependency issue with OAUTH).
From NuGet Uninstall Microsoft WebPages OAuth library
From PMC Install-Package Microsoft.AspNet.WebPages.WebData
Be sure to follow these steps as appropriate to your Project: Upgrade MVC 4 to 5 http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2
-- OR --
If you want to try Updating all your packages follow these steps:
From NuGet Uninstall Microsoft WebPages OAuth library (if using SimpleMembership, see above)
Had to individually update: 'Microsoft ASP.NET Web API Client Libraries and Core Libraries' and 'System.Spatial for OData'
Update All
From PMC Install-Package Microsoft.AspNet.WebPages.WebData (SimpleMembership, see above)
(See DbContext.EntityState above)
(web.config-root, add key="webpages:Version" value="3.0.0.0"; see Upgrade MVC 4 to 5 above; other changes were made automatically)
(Views web.config requires manual changes)
(Was then able to successfully Build and Open project but when it accessed the DB it required an update. (From PMC Update-Database. It failed with on “CREATE INDEX [xxxxxxx] ON [dbo].xxxxxxxx” “System.Data.SqlClient.SqlException (0x80131904): The operation failed because an index or statistics with name 'xxxxxxxx' already exists on table 'dbo.xxxxxxx'.”) but I was then able to successfully access the DB)
I was able to fix this by updating the configSection in the web.config of my views folder to match what I had in my packages.config. In my instance I needed to adjust the version for Razor to version 3.2.7
-- WEB.CONFIG
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.2.7.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.2.7.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.2.7.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
-- PACKAGES.CONFIG
<package id="Microsoft.AspNet.Mvc" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net45" />