Migration problem - EF thinks the database needs updating, projects that link to it will not be executed

So, last week I added some Migrations to my MVC portal project.

Something came, which meant that I had to roll back a specific migration.

My recent migration story:

201506101200157_userPermissions
201508181440262_API1
201508201305341_ContactUpdate
201508241312425_ApiLog
201508271518402_ActivityLog

The transference that I needed to deny was ContactUpdate, and I did something stupid to achieve this. Instead of just making changes and adding a new migration, I went back to API1, deleted the migration ContactUpdate, and then re-updated it to ActivityLog.

It seemed that everything was working fine, and my portal was working fine, I was not getting errors in the database in this project. But when I run add-migration, the up method is basically the down method from ContactUpdate, i.e. He still thinks he needs to come back to make the changes that I made.

The migration ContactUpdateinvolved adding two fields to my contact table. So, in a nutshell, this is the procedure I took:

  • Rollback to API1
  • Remove ContactUpdate Redirection
  • Updating the database to the latest migration
  • Remove two fields from the contact class

So, it’s pretty obvious why EF considers it necessary to delete these two columns when I deleted them after the last update.

A project that references this MVC project now fails

, ,

EF, , , . ?

+4
1

, ? .. ActivityLog, ContactUpdate?

, . . . Add-Migration Up Down.

NB , , , , , .

+2

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


All Articles