I am new to Asp.net and Visual Studio. I am developing a web application. I initially did it using MVC3 but i need to upgrade it to mvc4 now. I have tried lots of methods. From updating the files in the current project, to creating a new mvc4 webapp and then copying my models/controllers/views in it. I am aware of various links available on the internet.
In fact i tried the process that is mentioned on asp.net whitepapers as well http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253806
Tried the solution in this link too: Converting a ASP.NET MVC 3 Project to MVC 4
But it has been to no avail. The errors I keep getting are follows:
1. It first started with the error below:
[A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to [B]System.Web.WebPages.Razor.Configuration.HostSection.
I initially deleted the razor 4_02 from GAC folder and tried, but that failed. Then after i resolved that by managing the packages.config and making changes in web.config it did go away.
2. However, after doing this, when i started the web app, it showed a new error, as below:
'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
Now, according to what i read online, i uninstalled the Microsoft.AspNet.Mvc using Nuget and then installed package Razor-3.3.0 which failed. Afterwards, I installed package Razor-2.1.0 which was mentioned as a workaround in one of the responses online. And after that i installed Microsoft.AspNet.Mvc again. It was successful.
3. Again, when i ran the web app, this time it popped up a new error. This time the error was as below:
Compilation Error at '/'
Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0
I resolved this by removing the unused references as mentioned in one of the responses online. I also changed from System.Web.Webpages.Razor to System.Web.Razor
4. After solving that now it is showing me the error as below:
No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlServerCe.4.0'. Make sure the provider is registered in the 'entityFramework' section of the application config file.
Tried solution the links below:
5. I also got an error initially
error CS1705: Assembly 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' uses 'System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
I solved it using the solution given in the link below:
aspnet_compiler finding wrong version of System.Web.WebPages 1.0.0.0 instead of 2.0.0.0
I have tried changing the provider in the web.config and then i have also tried getting SqlServereCe4.0 dependencies when Visual Studio suggested that. It has been useless.
Apart from all the errors, i get warnings too.
As soon as i provide a provider, It shows a warning mentioning that
The element 'entityFramework' has invalid child element 'providers'. List of possible elements expected: 'contexts'
Another warning that I get:
The 'packages' element is not declared.
I have tried creating a packages.xsd file and then mapping that, but then it shows me another warning for packages.xsd mentioning that the xmlns can not contain text.
I have been trying for hours, but the problem does not seem to solve. Please help. I do not know what is going on. How can i upgrade it to MVC4??