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

asp.net-mvc-4 c# entity-framework sql-server

Question

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.

1
11
9/21/2013 6:10:55 AM

Accepted Answer

Yes you can use 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:

Update-Database

and you can specify your connection string name:

Update-Database -ConnectionStringName "MyConnectionString"
21
4/17/2017 6:00:21 PM

Popular Answer

This is best explained in the link below. Read the "Getting a SQL script" section. That will explain how to generate a script which you can then run on your target database.

This will be necessary if your database access is IP protected for example.

https://msdn.microsoft.com/en-us/data/jj591621.aspx



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow