MVC scaffolding does not support Entity Framework 6

asp.net-mvc entity-framework-6

Question

I'm trying to add a controller with read/write actions and views, using Entity Framework.

But when I try so, VS2012 tells me that "MVC scaffolding does not support Entity Framework 6 or later". I've read http://support.microsoft.com/kb/2816241 and tried to uninstall EntityFramework 6 and install 5 in Nuget Manager Console:

PM> Uninstall-package EntityFramework -force Removing 'EntityFramework 6.0.2' from OnlinebookingAdministrator. Successfully removed 'EntityFramework 6.0.2' from OnlinebookingAdministrator. Uninstalling 'EntityFramework 6.0.2'. Successfully uninstalled 'EntityFramework 6.0.2'.

PM> Install-Package EntityFramework -version 5.0.0 'EntityFramework 5.0.0' already installed. Adding 'EntityFramework 5.0.0' to OnlinebookingAdministrator. Successfully added 'EntityFramework 5.0.0' to OnlinebookingAdministrator.

But the error keeps showing up when I try to add the controller. Is there a solution to this?

Accepted Answer

Thought this could use some expanding :) As mentioned above ASP.NET MVC 4 scaffolding does not support EF6 or higher. This means that an older EF, compatible with MVC 4 will have to be installed. To do this:

  1. Open the Package Manager Console:
    • select TOOLS -> Library Package Manager -> Package Manager Console
  2. In the Package Manager Console, uninstall the current EF package by executing the following command:

    UnInstall-Package EntityFramework -Version <version number>

    *Where <version number> is the version number of the EF currently installed.
    *NOTE: to find out what EF version is installed, run the following command in the Package Manager Console:

    Get-Package EntityFramework

  3. To avoid potential metadata problems the providers entry in the Web.config file will need to be removed:

    • Open the Web.config file in the project directory.
    • Delete the following lines:

      <providers> <provider invariantName=System.Data.SqlClient type=System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer /> </providers>

  4. Now, in the Package Manager Console Execute the following command to install Entity Framework 5.0.0:

    Install-Package EntityFramework -Version 5.0.0


Popular Answer

After a bit more digging

ASP.NET MVC 4 scaffolding does not support Entity Framework 6 or higher. Support of scaffolding of Entity Framework 6 is targeted for the next release of ASP.NET MVC.

So looks like ill wait until MVC 5 is properly released




Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why