Reputation: 9073
I am working with Entity Framework code first. I have managed to work with migrations, but i need to type commands in the Package Manager Console. (for example Update-Database command). It works fine, but it works on my developpemnt computer.
Now, imagine i have a lot of production server. Some of those servers are still in database version 1, others in version 3 and the lastest version is 5. Is it possible to run the equivalent of Update-Database Command from C# Code ?
Upvotes: 1
Views: 2239
Reputation: 5630
DbUp is one other open source tool which is effective and provides robust features to perform production DB upgrade in EF Code first approach.
Here is an informative article comparing the Dbup open source tool vs EF migration feature.
Upvotes: 1
Reputation: 65860
Yes,you can do that.You have to change your web.config
file's connection string
according to your production server
and then run :
PM> Update-Database
Update : to generate scripts.
PM > Update-Database -Script -SourceMigration: $InitialDatabase -TargetMigration:
AddPostAbstract
You can refer this for more info : Getting a SQL Script
Upvotes: 0