简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM