在组装件''中找到了多个迁移配置类型.指定要使用的名称.在添加迁移时 [英] More than one migrations configuration type was found in the assembly ''. Specify the name of the one to use. On add-migration

查看:592
本文介绍了在组装件''中找到了多个迁移配置类型.指定要使用的名称.在添加迁移时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Package Manager控制台中,我正在尝试更新数据库.当我输入以下命令时:

add-migration Migration1

我明白了:

在程序集中发现了多个迁移配置类型 "MyProject.POCO".指定要使用的名称.

我搜索了错误,然后得到了这个消息:

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

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

解决方案

您的项目中有多个DbContext,您将需要指示哪些数据库将进行更新.这可以通过-ConfigurationTypeName完成. ConfigurationTypeName是迁移文件夹中Configuration类的名称.

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

您可以在此处了解更多信息.

In Package Manager Console, I'm trying to update my database. When I enter this command :

add-migration Migration1

And I get this :

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

I googled the error and I get this :

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

But I don't know how to apply this to my project. What should I write for ConfigurationTypeName? Or is there a simpler way to do this? Thanks.

解决方案

You have multiple DbContext in your project you will need to indicate which is going to have the database update. This can be done with -ConfigurationTypeName. The ConfigurationTypeName is the name of your Configuration class in your migration folder.

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

You can read more about it here.

这篇关于在组装件''中找到了多个迁移配置类型.指定要使用的名称.在添加迁移时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆