Ilya Leykin Ilya Leykin - 1 year ago 166
C# Question

How to update database on remote ms sql server (EF Code First)

While developing an application I used EF automatic migrations. So now when I have deployed my app on VPS, I don't know how to add new tables and fields to my database.

Can I connect to the remote database directly from my project in VS2012, updating a connection string, and update the database using "update-database" in package manager console? Or do I need to install VS on my VPS and update the database from VPS?

My database is already filled with data, so I can't delete it and create again.

Answer Source

yes you can using Visual Studio, follow this tutorial it should work for VS 2012 too.
you can also use Code first Migration to update your model by using this command in package manager console :


and you can specify your connection string name in above command :

Update-Database -ConnectionStringName "MyConnectionString"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download