运行 在 Visual studio 2017 年启用迁移时出错

Error while running Enable-Migrations in Visual studio 2017

我正在尝试通过关注 this tutorial 将我的网络应用程序从会员身份迁移到 ASP.Net 身份。但是当我执行 Enable-migrations 命令时出现此错误:

Blockquote PM> Enable-migrations System.ArgumentException: Paramètre incorrect. (Exception de HRESULT : 0x80070057 (E_INVALIDARG))

Server stack trace: à 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 msg)

Exception rethrown at [0]: à System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) à System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) à EnvDTE.Properties.Item(Object index) à System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetPropertyValue[T](Project project, String propertyName) à System.Data.Entity.Migrations.MigrationsDomainCommand.GetFacade(String configurationTypeName, Boolean 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 command) Paramètre incorrect. (Exception de HRESULT : 0x80070057 (E_INVALIDARG))

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

对于那些感兴趣的人,我终于在我的项目中创建了一个 c# 库(select 你的项目然后文件-> 新项目-> visual c# -> class 库)。我在这个库中进行了迁移,并将其添加为对我的项目的引用并且它起作用了。