Scaffolding EntityFramework 6 Unable to cast object of type 'System.Data.Entity.Core.Objects.ObjectContext' to 'System.Data.Objects.ObjectContext'

狂风中的少年 提交于 2020-01-12 03:40:09

问题


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


回答1:


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




回答2:


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!




回答3:


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



来源:https://stackoverflow.com/questions/19513599/scaffolding-entityframework-6-unable-to-cast-object-of-type-system-data-entity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!