While training ASP.NET MVC 4 recently, me and my class came across a very perculiar situation! You see I had requested my students to do a very small exercise available in the official Microsoft Course (20486B) Developing ASP.NET MVC 4 Web Applications manual. This very simple exercise involved creating a single model class and the associated controller, then through the “almighty” scaffolding framework in MVC 4 generate some basic views. Everything was going ok in the exercise until we downloaded the Entity Framework Nuget package!
The steps to follow where pretty simple as step 1 involved invoking the Nuget Package Manager via right clicking on the References, then choose Manage NuGet Packages.
After that, we searched for right package we were interested in, the Nuget Package Manager displayed as below.
We were obviously all too happy that the Nuget search page was quite efficient to display the Entity Framework we were looking for. Right? Wrong! You see, if you are still running off ASP.NET MVC 4, this is where you must put brakes immediately! The latest version of ASP.NET MVC available now (well at the least at the time this blog post was written) is MVC 5.
Hence It also follows that some of the key Nuget packages available have also been updated to cater for MVC 5 and the Entity Framework package is one of them, now available as version 184.108.40.206 yet MCV 4 requires Entity Framework version 5. So if you proceed to install the package displayed above in your application you will not be able to do scaffolding for your existing models.
Hence the solution would be to manually install Entity Framework 5 by executing the PM command in the Package Manager console. So you nee to follow these steps:
1) Browse for Entity Framework online and obtain the correct command line:
2) Invoke the Package Manager Console in Visual Studio:
3) Execute the PM command provided online in the Package Manager Console. Visual Studio will take a few seconds to install the package:
Once done, your ASP.NET will you will be guaranteed hassle free Scaffolding, thanks to the now elusive Entity Framework 5 package for ASP.NET MVC 4