How to update database on remote ms sql server (EF code first)

When developing the application, I used automatic EF migrations. So now that I have deployed my application to VPS, I don’t know how to add new tables and fields to my database.

Is it possible to connect to a remote database directly from my project in VS2012, update the connection string and update the database using "update-database" in the 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 not delete it and create it again.

+7
c # sql-server entity-framework asp.net-mvc-4
source share
2 answers

Yes, you can use Visual Studio, follow this tutorial - it should work on VS 2012 as well.
You can also use "First Code Migration" to update your model with this command in the package manager console:

Update-Database 

and you can specify the name of the connection string:

 Update-Database -ConnectionStringName "MyConnectionString" 
+14
source share

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

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

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

+2
source share

All Articles