Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

I am developing a mvc 5 application using code first approach.

i am facing an issue . at first time when i try below comands , it worked and generate the table in that database. but when i changed some more classes and then tried with first 2 queries , it worked in that case but when i tried the third command, it gave this message to me.

 First step ==========  enable-migrations -ContextTypeName IdentityDb -MigrationsDirectory DAL\IdentityMigrations  enable-migrations -ContextTypeName SMSContext -MigrationsDirectory DAL\SMSMigrations  Second Step ===========  add-migration -ConfigurationTypeName SMSApp.DAL.IdentityMigrations.Configuration "InitialCreate"  add-migration -ConfigurationTypeName SMSApp.DAL.SMSMigrations.Configuration "InitialCreate"  Third Step ==========  update-database -ConfigurationTypeName SMSApp.DAL.IdentityMigrations.Configuration -verbose  update-database -ConfigurationTypeName SMSApp.DAL.SMSMigrations.Configuration -verbose  

see the first error:

PM> add-migration -ConfigurationTypeName SMSApp.DAL.IdentityMigrations.Configuration "InitialCreate" Scaffolding migration ' '. The Designer Code for this migration file includes a snapshot of your current Code First model. This snapshot is used to calculate the changes to your model when you scaffold the next migration. If you make additional changes to your model that you want to include in this migration, then you can re-scaffold it by running 'Add-Migration InitialCreate' again.  A previous migration called 'InitialCreate' was already applied to the target database. If you meant to re-scaffold 'InitialCreate', revert it by running 'Update-Database -TargetMigration $InitialDatabase', then delete '201409261933262_InitialCreate1.cs' and run 'Add-Migration InitialCreate' again. 

After that i executed the below command, it gave the below exception.

Update-Database -TargetMigration $InitialDatabase -verbose

PM> Update-Database -TargetMigration $InitialDatabase -verbose Using StartUp project 'SMSApp'. Using NuGet project 'SMSApp'. 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 'SMSApp'. Specify the name of the one to use.    at 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)    at System.Data.Entity.Migrations.Utilities.MigrationsConfigurationFinder.FindMigrationsConfiguration(Type contextType, String configurationTypeName, Func`2 noType, Func`3 multipleTypes, Func`3 noTypeWithName, Func`3 multipleTypesWithName)    at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.FindConfiguration()    at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.GetMigrator()    at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.Run()    at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)    at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)    at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)    at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force)    at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()    at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command) More than one migrations configuration type was found in the assembly 'SMSApp'. Specify the name of the one to use. 

NOw i am worry how to resolve it?

like image 759
maifs Avatar asked Sep 26 '14 19:09

maifs


People also ask

Which command is used to run migration?

Open the Package Manager Console from Tools → Library Package Manager → Package Manager Console and then run the enable-migrations command (make sure that the default project is the project where your context class is).

How to add ef migration?

Migrations are enabled by default in EF Core. They are managed by executing commands. If you have Visual Studio, you can use the Package Manager Console (PMC) to manage migrations. Alternatively, you can use a command line tool to execute Entity Framework CLI commands to create a migration.

What does enable migrations do?

The enable-migrations command creates a Migrations folder in the ContosoUniversity project, and it puts in that folder a Configuration. cs file that you can edit to configure Migrations.


1 Answers

You need to specify which configuration you want to use when updating the databases.

Update-Database -ConfigurationTypeName MyRenamedConfiguration 
like image 70
Amirhossein Yari Avatar answered Sep 27 '22 17:09

Amirhossein Yari