Last post May 16, 2016 07:54 AM by Mikesdotnetting
May 16, 2016 05:33 AM|lolo512|LINK
I have a project with Code first migration already set .I just want to run these migrations
can anyone please guide me how to do so
this is what I have tried so far
.\packages\FluentMigrator.18.104.22.168\tools\migrate -conn "server=myservername;uid=myUser;pwd=myPass;database=myDB" --provider sqlserver2014 --assembly ".\bin\Debug\FluentMigratorSample.dll"
but of course since I don't know what each component means then it throws an error.sure I'm missing something
This is the error I received
The term '.\packages\FluentMigrator.22.214.171.124\tools\migrate' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spellin
g of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:48
+ .\packages\FluentMigrator.126.96.36.199\tools\migrate <<<< -conn "server=myServername;uid=user;pwd=pass;database=db" --provider sqlserver2014 --assem
+ CategoryInfo : ObjectNotFound: (.\packages\Flue...0\tools\migrate:String) , CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
May 16, 2016 06:40 AM|Mikesdotnetting|LINK
I don't know why you are using the FluentMigrations package. Migrations are included in Entity Framework by default these days. Check this tutorial on how to enable, create and run a migration: http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/migrations-and-deployment-with-the-entity-framework-in-an-asp-net-mvc-application
May 16, 2016 06:49 AM|lolo512|LINK
since I already have the migrations classes with the configuration.cs, I will only update-datbase
but it gave me the following error:
More than one migrations configuration type was found in the assembly 'myProjName'. Specify the name of the one to use.
can you please explain to me more details what to do
May 16, 2016 07:17 AM|Mikesdotnetting|LINK
It sounds like you have created more than one configuration for migrations (i.e. class that implements DbMigrationsConfiguration<T>). You need to specify which one to use when calling update-database:
update-database -configurationtypename your_selected_configuration
Or you need to delete the one that you don't need if one was created in error.
May 16, 2016 07:28 AM|lolo512|LINK
I only have 1 configuration file.please can you be more specific
May 16, 2016 07:54 AM|Mikesdotnetting|LINK
I only have 1 configuration file
The error message says that you have more than one class that implements DbMigrationsConfiguration<T> in your project. They can be called anything, but the default name is Configuration. A Configuration.cs class is added when you enable migrations. It contains
the following code:
internal sealed class Configuration : DbMigrationsConfiguration<YourContext>
When you try to add a migration or run it, the framework looks for a class that implements DbMigrationsConfiguration for configuration instructions such as where the migrations directory is, whether automatic migrations are enabled and so on. If it finds
more than one class that implements DbMigrationsConfiguration, the error message that you get is produced.