After upgrading from EF 6.2 to 6.3 the command 'update-database' not working with more 'configuration type name' in the same solution.
PM> update-database -ConfigurationTypeName VipERP.Data.Migrations.ERP.Configuration -verbose
D:\Repositorio\VipERP\packages\EntityFramework.6.3.0\tools\net45\win-x86\ef6.exe database update --verbose --no-color --prefix-output --assembly D:\Repositorio\VipERP\source\VipERP.Data\bin\Debug\VipERP.Data.dll --project-dir D:\Repositorio\VipERP\source\VipERP.Data\ --language C# --root-namespace VipERP.Data --config D:\Repositorio\VipERP\source\VipERP.Retaguarda\App.config
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
System.Data.Entity.Migrations.Infrastructure.MigrationsException: More than one migrations configuration type was found in the assembly 'VipERP.Data'. Specify the name of the one to use.
em System.Data.Entity.Utilities.TypeFinder.FindType(Type baseType, String typeName, Func`2 filter, Func`2 noType, Func`3 multipleTypes, Func`3 noTypeWithName, Func`3 multipleTypesWithName)
em System.Data.Entity.Migrations.Utilities.MigrationsConfigurationFinder.FindMigrationsConfiguration(Type contextType, String configurationTypeName, Func`2 noType, Func`3 multipleTypes, Func`3 noTypeWithName, Func`3 multipleTypesWithName)
em System.Data.Entity.Infrastructure.Design.Executor.GetMigrationsConfiguration(String migrationsConfigurationName)
em System.Data.Entity.Infrastructure.Design.Executor.UpdateInternal(String targetMigration, Boolean force, DbConnectionInfo connectionInfo, String migrationsConfigurationName)
em System.Data.Entity.Infrastructure.Design.Executor.Update.<>c__DisplayClass0_0.<.ctor>b__0()
em System.Data.Entity.Infrastructure.Design.Executor.OperationBase.Execute(Action action)
More than one migrations configuration type was found in the assembly 'VipERP.Data'. Specify the name of the one to use.
EF version: 6.3.0
Database Provider: EntityFramework.SqlServer
Operating system: Windows 10
IDE: Visual Studio 2019 Version 16.3.0
.
Copy the ef6.exe command and add it there:
D:\Repositorio\VipERP\packages\EntityFramework.6.3.0\tools\net45\win-x86\ef6.exe database update --verbose --no-color --prefix-output --assembly D:\Repositorio\VipERP\source\VipERP.Data\bin\Debug\VipERP.Data.dll --project-dir D:\Repositorio\VipERP\source\VipERP.Data\ --language C# --root-namespace VipERP.Data --config D:\Repositorio\VipERP\source\VipERP.Retaguarda\App.config --migrations-config VipERP.Data.Migrations.ERP.Configuration
This resolved. Thanks
FYI, this fix is included in our daily builds (see link for setup instructions). Feel free to start using it today via the version 6.4.0-preview1-* prerelease packages.
The solution suggested fixed the issue with update-database. But add-migration then still fails with :
Unable to generate an explicit migration because the following explicit migrations are pending: [XXX]. Apply the pending explicit migrations before attempting to generate a new explicit migration
even though I specify a ConfigurationTypeName which is different.
Are multiple contexts supported at all ? Or is it still an experimental feature ?
Most helpful comment
Workaround
Copy the
ef6.execommand and add it there: