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
email
in the tableUserProfile
. However, I cannot enable database migration on the defaultUsersContext
since I already enabled migration onMyContext
. I had to delete the database and let it recreateUserProfile
table (I had to open the user register page first, otherwise it will createUserProfile
without 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
UsersContext
were 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
MyContext
and 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?