【问题标题】:More than one migrations configuration type was found in the assembly ''. Specify the name of the one to use. On add-migration在程序集“”中发现了多个迁移配置类型。指定要使用的名称。在添加迁移
【发布时间】:2016-12-28 05:03:29
【问题描述】:

在包管理器控制台中,我正在尝试更新我的数据库。当我输入这个命令时:

add-migration Migration1

我明白了:

在程序集中发现了多个迁移配置类型 '我的项目.POCO'。指定要使用的名称。

我用谷歌搜索了错误,我得到了这个:

add-migration InitialBSchema -IgnoreChanges -ConfigurationTypeName
ConfigurationB -ProjectName ProjectContextIsInIfNotMainOne
-StartupProjectName NameOfMainProject  -ConnectionStringName ContextB

但我不知道如何将它应用到我的项目中。我应该为 ConfigurationTypeName 写什么?或者有没有更简单的方法来做到这一点?谢谢。

【问题讨论】:

    标签: c# migration code-first entity-framework-migrations


    【解决方案1】:

    您的项目中有多个DbContext,您需要指明哪个将更新数据库。这可以通过-ConfigurationTypeName 完成。 ConfigurationTypeName 是迁移文件夹中配置类的名称。

    Add-Migration -Name Migration1 -ConfigurationTypeName MyProject.POCO.Configuration

    您可以阅读更多关于它的信息here.

    【讨论】:

      猜你喜欢
      • 2014-11-21
      • 2018-03-04
      • 2016-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-21
      相关资源
      最近更新 更多