14

I guess I should have thought of this before I started my project but I have successfully built and tested a mini application using the code-first approach and I am ready to deploy it to a production web server.

I have moved the folder to my staging server and everything works well. I am just curious if there is a suggested deployment strategy?

If I make a change to the application I don't want to lose all the data if the application is restarted.

Should I just generate the DB scripts from the code-first project and then move it to my server that way?

Any tips and guide links would be useful.

Thanks.

0

2 Answers 2

5

Actually database initializer is only for development. Deploying such code to production is the best way to get some troubles. Code-first currently doesn't have any approach for database evolution so you must manually build change scripts to your database after new version. The easiest approach is using Database tools in VS Studio 2010 Premium and Ultimate. If you will have a database with the old schema and a database with the new schema and VS will prepare change script for you.

Sign up to request clarification or add additional context in comments.

3 Comments

Pardon my ignorance. But could you outline the steps I should take to move this project to my production server?
I too would like more info, @Ladislav
I would also like more info! There are restrictions locally such as the 4k string limit (I need max for production)... so, how do I create/get the final schema?
1

Here are the steps I follow.

  1. Comment out any Initialization strategy I'm using.
  2. Generate the database scripts for schema + data for all the tables EXCEPT the EdmMetadata table and run them on the web server. (Of course, if it's a production server, BE CAREFUL about this step. In my case, during development, the data in production and development are identical.)
  3. Commit my solution to subversion which then triggers TeamCity to build, test, and deploy to the web server (of course, you will have your own method for this step, but somehow deploy the website to the web server).
  4. You're all done!

The Initializer and the EdmMetadata tables are needed for development only.

2 Comments

Yes, this is essentially the manual way to do what a Visual Studio Database Project does automatically for you. kingdango.com/blog/2011/12/…
NOTE: you can use preprocessor directives to automatically remove the SetInitializer msdn.microsoft.com/en-us/library/4y6tbswk.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.