Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm working in a project that uses EF Code First. I'm trying to use migration features. I don't want to use Package Console Manager. How can I execute the "Add-Migration" and "Update-Database" programmatically?

add-migration TestMigration01 -force

update-database
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
362 views
Welcome To Ask or Share your Answers For Others

1 Answer

You have a couple of choices. You can use the dbmigrator class from within your code: http://romiller.com/2012/02/09/running-scripting-migrations-from-code/

Or you can use migrate.exe which is handy for running them in a build step, etc. https://msdn.microsoft.com/en-us/data/jj618307.aspx


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...