【发布时间】:2013-04-08 21:08:57
【问题描述】:
如何在 Visual Studio 2012 的 WebForms 网站项目(不是 Web 应用程序项目)中启用实体框架?
编辑 1:我使用的是 Framework 4.0。我已经使用包管理器控制台安装了 Entity Framework 5.0。在包管理器控制台中执行 Enable-Migrations 时会抛出错误。
PM> enable-migrations
System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
Server stack trace:
at EnvDTE.Properties.Item(Object index)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at EnvDTE.Properties.Item(Object index)
at System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetPropertyValue[T](Project project, String propertyName)
at System.Data.Entity.Migrations.MigrationsDomainCommand.GetFacade(String configurationTypeName)
at System.Data.Entity.Migrations.EnableMigrationsCommand.FindContextToEnable(String contextTypeName)
at System.Data.Entity.Migrations.EnableMigrationsCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
【问题讨论】:
-
您使用的是什么版本的 Visual Studio(如果有),您安装的 .NET Framework 的最新版本是什么?这些将决定您当前拥有的 EF 支持级别。您也可以单独下载 EF 更新。
-
Visual Studio 2012(有问题的说)。我已经安装了所有框架。我需要它来使用 Framework 4.0。
标签: asp.net entity-framework webforms