Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy Entity Framework Code First

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.

like image 747
KidCoke Avatar asked Apr 06 '11 22:04

KidCoke


People also ask

How do I use code first in Entity Framework?

Step 1 − First, create the console application from File → New → Project… Step 2 − Select Windows from the left pane and Console Application from the template pane. Step 3 − Enter EFCodeFirstDemo as the name and select OK. Step 4 − Right-click on your project in the solution explorer and select Manage NuGet Packages…

Which is better code first or database first in Entity Framework?

Versioning databases is hard, but with code first and code first migrations, it's much more effective. Because your database schema is fully based on your code models, by version controlling your source code you're helping to version your database.


1 Answers

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.

like image 160
Ladislav Mrnka Avatar answered Sep 28 '22 05:09

Ladislav Mrnka