Using EF4 Code First: How can I change the Model without losing data Using EF4 Code First: How can I change the Model without losing data asp.net asp.net

Using EF4 Code First: How can I change the Model without losing data


Initializer is for development. I consider any automatic process changing your production database directly from application as evil. Somebody else can simply forget the existence of it, redeploy single .dll and your database is gone.

Database upgrade is operation which should be executed separately as part of upgrade script, installation package or manual upgrade during application maintenance and not during first request to the new version. I described migration yesterday.

What you are looking for is custom intializer which would execute external script created in my linked answer. That can be partially working if you include a lot of additional checks which will avoid running script twice. But why? Once you have a script you can simply execute it once an you are done.