首页 > 解决方案 > 在 Visual Studio 2017 中运行 Enable-Migrations 时出错

问题描述

我正在尝试按照本教程将我的 Web 应用程序从会员身份迁移到 ASP.Net 身份。但是当我执行 Enable-migrations 命令时出现此错误:

Blockquote PM> Enable-migrations System.ArgumentException: Paramètre 不正确。(HRESULT 异常:0x80070057 (E_INVALIDARG))

服务器堆栈跟踪: à EnvDTE.Properties.Item(Object index) à System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs) à System.Runtime.Remoting .Messaging.StackBuilderSink.SyncProcessMessage(IMessage 消息)

[0] 处重新抛出异常:à System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) à System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)à EnvDTE.Properties。项目(对象索引)à System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetPropertyValue[T](项目项目,字符串 propertyName)à System.Data.Entity.Migrations.MigrationsDomainCommand.GetFacade(字符串 configurationTypeName,布尔 useContextWorkingDirectory)à System .Data.Entity.Migrations.EnableMigrationsCommand.FindContextToEnable(String contextTypeName) à System.Data.Entity.Migrations.EnableMigrationsCommand.<>c__DisplayClass2.<.ctor>b__0() à System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action命令)参数不正确。(HRESULT 异常:0x80070057 (E_INVALIDARG))

我尝试使用参数 -ProjectName 和 -StartUpProjectName 但它不起作用。我使用 EntityFramework 6.2.0。请需要帮助。

标签: asp.netentity-frameworkentity-framework-migrations

解决方案


对于那些有兴趣的人,我终于在我的项目中创建了一个库 ac#(选择你的项目然后文件-> 新项目-> 可视化 c#-> 类库)。我在这个库中进行了迁移,并将其添加为对我的项目的引用,并且它有效。


推荐阅读