【问题标题】:Error while running Enable-Migrations in Visual studio 2017在 Visual Studio 2017 中运行 Enable-Migrations 时出错
【发布时间】:2019-03-29 03:47:01
【问题描述】:

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

块引用 PM> 启用迁移 System.ArgumentException:参数不正确。 (HRESULT 异常:0x80070057 (E_INVALIDARG))

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

在 [0] 处重新抛出异常: à System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) à System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 类型) à EnvDTE.Properties.Item(对象索引) à 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(动作命令) 参数不正确。 (HRESULT 异常:0x80070057 (E_INVALIDARG))

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

【问题讨论】:

  • 您的解决方案结构是什么样的?您的模型类是否与 Web 应用程序分开到不同的项目中?
  • @user1011627,我所有的课程都在同一个项目中
  • 你能显示你正在尝试运行的实际命令吗?
  • 另外,您在 web.config 中是否有项目的“全球化”部分?
  • enable-migrations -ProjectName myAppenable-migrations -StartUpProjectName myApp。 myApp 是项目的名称。

标签: asp.net entity-framework entity-framework-migrations


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2016-04-25
    • 2018-09-01
    • 2016-04-04
    • 1970-01-01
    • 1970-01-01
    • 2017-04-04
    • 2018-07-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多