During my Global.asax I possess the following line:
Database.SetInitializer<myDbSupport> (new DropCreateDatabaseIfModelChanges<myDbSupport>());
Basically do not have this, when i alter the model, the sdf database won't have the right structure. This really is ok inside a dev atmosphere, however when I proceed to production and wish a DB structure update, i obviously, can not afford to decrease the table, and lose the information.
Can you really script DB changes, and run this update before implementing the model using the transformed structure?
Initializer is perfect for development. I consider any automatic process altering your production database from application as evil. Someone else can easily forget the presence of it, redeploy single .dll as well as your database is finished.
Database upgrade is operation that ought to be performed individually included in upgrade script, installation package or manual upgrade throughout application maintenance and never throughout first request towards the latest version. I described migration yesterday.
What you're searching for is custom intializer which may execute exterior script produced during my linked answer. That may be partly working should you include lots of additional inspections that will avoid running script two times. Why? After you have a script you can just carry it out once an you're done.