Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 网站实体框架迁移异常_Asp.net_Entity Framework_Database Migration - Fatal编程技术网

Asp.net 网站实体框架迁移异常

Asp.net 网站实体框架迁移异常,asp.net,entity-framework,database-migration,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 inde

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

建立数据库模型后,我可以轻松地在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))
System.ArgumentException:参数不正确。(HRESULT的例外情况:0x80070057(E_INVALIDARG))
服务器堆栈跟踪:
位于EnvDTE.Properties.Item(对象索引)
在System.Runtime.Remoting.Messaging.StackBuilderSink.\u PrivateProcessMessage(IntPtr md,对象[]参数,对象服务器,对象[]和输出参数)
在System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)中
在[0]处重试异常:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)
at System.Runtime.Remoting.proxy.RealProxy.PrivateInvoke(MessageData&msgData,Int32类型)
位于EnvDTE.Properties.Item(对象索引)
位于System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetPropertyValue[T](项目项目,字符串propertyName)
位于System.Data.Entity.Migrations.MigrationsDomainCommand.GetFacade(字符串配置类型名称)
位于System.Data.Entity.Migrations.EnableMigrationsCommand.FindContextToEnable(字符串contextTypeName)
在System.Data.Entity.Migrations.EnableMigrationsCommand.c__DisplayClass2.b__0()中
位于System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(操作命令)
参数不正确。(HRESULT的例外情况:0x80070057(E_INVALIDARG))
我能怎么办?
问题2。如果我创建了一个web应用程序项目,如何部署它?除了FTP,我不知道部署网站的其他方法。

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

Q1。您如何运行迁移?问题2。看看我刚才键入的web部署启用迁移。这就是全部。我不知道我应该为其他参数设置什么我有这个确切的问题。实体框架在web应用程序和控制台应用程序中使用“启用迁移”可以正常工作。然而,当尝试在网站项目中使用它时,我会收到错误消息,但我发现没有任何帮助(主要是人们说要将项目名称传递到命令中,但这也不起作用)哦,是的。迁移只适用于web应用程序。它不适用于网站项目。