在程序集“”中发现了不止一种迁移配置类型。指定要使用的名称。添加迁移

More than one migrations configuration type was found in the assembly ''. Specify the name of the one to use. On add-migration

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

add-migration Migration1

我明白了:

More than one migrations configuration type was found in the assembly 'MyProject.POCO'. Specify the name of the one to use.

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

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

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

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

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

您可以阅读更多相关信息here.