I have a MVC code first solution and I have the solution running on my production server.
I now have some changes to the model and that gives me a new empty database on my development computer.
My questions is now:
1) What is the best way to get the data from the production database to my development computer?
I have tried to generate “data-only” scripts from production but that did not work.
2) What is the best way to implement the new structure to the production server without losing data?
I am using VS2012 professional.
EDIT
The following worked for me
1) Backup of the db om the prod server and restore on the local
2) Using the schema compare in VS2012 to update the schema on the db restored db
3) Rename the restored db to the orginal name local (now I have a local db with the data from prod and the right schema)
4) Backup of the local db and restore on the server (now the db on the server have the right schema)
The only glitch whas that I had to replace
Database.SetInitializer(new myDbInitializer());
with
Database.SetInitializer < myContext > (null);
To make sure the system don’t try to drop/create the db.
Unless security is an issue, backup / restore. That sometimes does not work legally, then it is backup / restore / scramble or a data generator (if the developer is not allowed to see the data).
Generate a script to update the database. Point.
Sadly, “Point” like in “Hollywood sign large letters” as it is an area you are left on your own with. You can do schema compares, even generate delta scripts, but they are SERIOUSLY primitive. Inserts (metadata), cleanup operations, renames will result in problems.
Best is:
Actually likely BEST way as there are tons of things that the schema delta can not properly handle.
One example – we are now takin a denormalized table and normalize it (into 4), then replace it ith a view.
The delta script must generate the normalized values, the new table, do the insert there, then generate teh view.
There is logic involved – the automatic delta can not handle it.