How to use migration programmatically in EntityFramework Codefirst?

I am working on a project that uses EF Code First. I am trying to use migration functions. I do not want to use the package manager. How can I programmatically execute "Add-Migration" and "Update-Database"?

add-migration TestMigration01 -force update-database 
+7
c # entity-framework ef-code-first entity-framework-6 ef-migrations
source share
1 answer

You have several options. You can use the dbmigrator class from your code: http://romiller.com/2012/02/09/running-scripting-migrations-from-code/

Or you can use migrate.exe, which is convenient for running them at the build stage, etc. https://msdn.microsoft.com/en-us/data/jj618307.aspx

+10
source share

All Articles