EF (Entity Framework) 4.3 Migration tool does not work with EF 4.1 DB

I want to change one database that was developed using EF 4.1 (Code First). I have updated the project in EF 4.3 and follow these steps: http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-automatic-migrations-walkthrough.aspx

Everything is going well, but when I want to test the current database (first EF 4.1 Code), Update-Database raises this error:

The following migration is not possible because the target database was created with Code First before EF 4.3 and does not contain a migration history table. To start using migrations against this database, make sure that the current model is compatible with the target database and complete the migration upgrade process. (In Visual Studio, you can use the Update-Database command from the Package Manager console to complete the migration upgrade process.)

I was wondering how can I migrate the EF 4.1 database (Code First)? Besides that, DB is alive and has data, and I cannot refuse tables.

+6
source share
2 answers

You need to create an empty migration and execute it before making changes to your model. He will create a migration history table for you. After that, you can use migrations for new changes. I wrote an article about this topic.

+8
source

Run "Add-Migration InitialMigration -IgnoreChanges" before making any changes to the model. Make the necessary changes, then run "update-database"

0
source

Source: https://habr.com/ru/post/909776/


All Articles