I created an internet asp.net Mvc 4 application. It used EF5 code first, LocalDB by default. I have the following issues. I put all my tables in data context class MyContext and enabled database migration on it.
UsersContext. I added a field
emailin the tableUserProfile. However, I cannot enable database migration on the defaultUsersContextsince I already enabled migration onMyContext. I had to delete the database and let it recreateUserProfiletable (I had to open the user register page first, otherwise it will createUserProfilewithout fieldemail.)I published the project to a server with IIS/Sql Server and keep working on the project. However, from time to time it shows the model of
UsersContextwere changed (not true) and I had to delete the database on the live server and let it recreate the database.Sometimes it create the same index twice on a table in
MyContextand it failed the migration. And I had to delete the database again for recreating.
How to prevent the above issues? Should database migration be disabled after go live? How to apply the Model/DB changes?