I use EF Code First in my solution with SQL Server Express behind it. When I update my model, I always have to delete my database before restarting my solution. I know this is because my database is no more up to date. In that case, I lose all data in my tables.
I would like to be able to update my models (for example: adding a new field) and keeping all data in my tables.
Even if I update manually my database, when I restart the solution, I get the error below:
The model backing the ‘EntityFrameworkDbContext’ context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance
Any suggestions?
Thanks.
You can remove the creation of EdmMetadata table as follows.
This way you can manually update the database without getting the error.
You can check out Code First Migrations