I’m trying to get a grip on Code First and so far every time I make a change to a model I need to drop and recreate the database. What about the data that’s currently in the database? I just find it annoying that I have to do this every time and doesn’t make for a a good web approach unless you are 100% sure you’ll never have to make a change such as adding a new column in a table. Is there another way to prevent this from happening?
Share
By default database initializer is set to DropCreateDatabaseIfModelChnages. you can set the database initializer to null to avoid recreating,
The other option is to use Database Migrations to update database without recreating it.