网站实体框架迁移ArgumentException

时间:2013-04-22 05:49:45

标签: asp.net entity-framework database-migration

我正在学习如何使用实体框架

设置数据库模型后,我可以轻松地在Web应用程序和控制台项目中执行迁移。

但是当我在网站项目中创建数据库模型并执行迁移时,控制台会提示我

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))

我该怎么办呢? Q2。如果我创建一个Web应用程序项目,我该如何部署它?除了FTP,我不知道任何其他方式来部署网站。

1 个答案:

答案 0 :(得分:0)

不确定导致此问题的原因,但您可以通过创建包含模型和上下文的单独程序集来解决问题,然后在该项目上启用迁移。从您的网站项目中引用该项目。