How to Update Migration DB Entity Framework in Server Production

asp.net-mvc asp.net-web-api2 entity-framework entity-framework-6

Question

I have created a web-based application using Asp.Net MVC and Entity Framework 6. Currently the app has been installed on the production server my client. A few weeks ago, my client wants additional modules of applications that are already running today. Certainly in terms of programming code there are several additional classes of models and properties for the new table. My question is:

  1. How do I update the database schema in a production server, which of visual studio I do not have direct access to the existing database on the production server. This is the essence of my case..

  2. Is there a way or a good move for my case. please his explanations and his guidance.

as additional information :

  1. my Client apply a fairly strict security during the process of installing applications to a production server. Her intent is when the process of entering into the application server production not by me, but by their own internal teams with the reference of the installation documentation from my program.

  2. Server application and database servers separately.

  3. I use entity framework - code first (with DropCreateDatabaseIfModelChanges).

so many of my questions, thank you for all the attention and his answers. I really appreciate the time you spend in the form of answers that could provide a solution in the form of comment or opinion. Thanks.

1
1
9/30/2016 1:28:43 PM

Accepted Answer

OP 1 :

I use entity framework - code first (with DropCreateDatabaseIfModelChanges).

Ans :

This is Wrong approach when you deal with the production database.What will happen to your production data on the db if you do this way ? All will be lost each and every time when you do the data migration.So the recommended way for production is CreateDatabaseIfNotExists.

CreateDatabaseIfNotExists :

This is default initializer. As the name suggests, it will create the database if none exists as per the configuration.

OP 2 :

How do I update the database schema in a production server ?

Ans :

You can create a Sql script using below command.After that you can use it to run on your production SQL sever.

Run this on the Package Manger console :

PM > Update-Database -Script

You can get more info here : Getting a SQL Script

0
9/30/2016 2:18:16 PM


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