I am developing in MVC 4, EF 5.0
Model First development - how do I 'easily' get the DB schema to update, without having to drop the database / erase any data?
e.g. I have a Customer table. In this table, we capture name, surname, email address. I now want to collect the telephone number, so I change the model and get EF to update the database schema.
Visual studio 2012 referrs me to http://go.microsoft.com/fwlink/?LinkId=238269, however this looks like chinese to me.
They talk about running an NUGET package called code first migrations. Does this functionality not come packaged automatically with VS2012?
Thanks
Drop and Recreate Your Database You can configure Entity Framework to delete (drop) and recreate your database every time there is a change to your schema. To do this, you need to create an initializer class in the same folder as your DbContext class. The class needs to inherit from DropCreateDatabaseIfModelChanges .
Database migrations is what you are looking for. Both automatic and specified in code - http://msdn.microsoft.com/pl-PL/data/jj591621
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With