7

I wanna use Scaffolding in EntityFrameWork 6, but get this:

Unable to retrieve metadata for '[myNameSpace].Models.prod'. Unable to cast object of type 'System.Data.Entity.Core.Objects.ObjectContext' to type 'System.Data.Objects.ObjectContext'.

Does EF 6 support scaffolding?

Update

After some while, microsoft realease new upgrade for support scafolding and some others features

I think it doesn't work while you upgrade vs IDE to 2013

Mohammadreza
  • 3,139
  • 8
  • 35
  • 56
  • Hi Edalat, do you make works the EF 6 with Scaffolding? I'm using ASP.NET MVC 4 with EF 6 and I tryed update to ASP.NET MVC 5 without sucess. I used this tutorial to upgrade to MVC 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 but the error persists. What did you do for work? What do you have installed? – ViniciusdeLemos Jan 24 '14 at 11:09
  • 1
    Hi @ViniciusdeLemos I installed vs 2013 and it works – Mohammadreza Jan 27 '14 at 09:53
  • 1
    I think it doesn't work while you upgrade vs IDE to 2013 – Mohammadreza Jan 27 '14 at 09:55

3 Answers3

11

I'm sorry but it is not supported ASP.NET MVC 4 scaffolding does not support Entity Framework 6 or later

Raphael
  • 1,677
  • 1
  • 15
  • 23
5

I was battling with this kind of problem for almost 3 days, but I later found two solutions:

Command

  1. Open an empty MVC Solution
  2. Open your Package manager console
  3. Type this command (Install-Package EntityFramework -Version 5.0.0 )

Default Framework

Select an internet application option of the ASP.NET MVC project template on Visual Studio 2012. By default Entity framework 5 came with it so there is no need to run your package manager console again.

Best of luck!

Alice
  • 3,958
  • 2
  • 24
  • 28
Jemil Oyebisi
  • 633
  • 8
  • 10
1

ASP.NET MVC 4 scaffolding does not support Entity Framework 6 or later version.

1.Need to uninstall Entity framework6 or later version Tools->NuGet package manager->Package manager console PM> uninstall-package entityframework -version 6.1.1

2.Install entity framework 5

PM> install-package entityframework -version 5.0.0.0

3.Need to change web.config

To change as it bellow

Sankar
  • 21
  • 1