In a team environment, we have one member with a database that already has some of the tables in the model but no Migration History table. Using EF Automatic Migrations, how do we upgrade the database so it will create the history table, add the missing tables, and alter/upgrade existing ones? We need to upgrade that member's database because the existing tables have data.
Asked
Active
Viewed 737 times
1 Answers
1
I think that EF does not support your scenario, but keep looking.
If I needed to do this, I would:
- Create an empty project
- Reverse engineer the current DB to a set on EF entities
- Have that project create a new DB, which will include the history table
- Copy the history table to the main DB
- Run the main Application to upgrade the database
Of course I would take a backup first, and would name the temp project and its DbContext the same as the main project, in case EF somehow includes them in the history table.
There is also another way to do that:
- Have EF create tables on an empty DB
- Copy all of that user's data from their old DB, using SSMS import/export wizard
Which one I suggest: the second one, which one I would do: the first, as it is the more adventurous one!

Alireza
- 5,421
- 5
- 34
- 67