简体   繁体   中英

Exception calling "Remove" with "0" argument(s): "The given key was not present in the dictionary

I have added a migration using Add-Migration , Now If I run Remove-Migration , it reverts the migration and remove the generated migration file successfully, but gives the error in Package Manager Console also. I could not figure out the exact reason behind it and side effect of it. Is this EF Core bug?

Package Manager Output:

PM> Remove-Migration Removing migration '20180320052521_testMigration'. Reverting model snapshot. Done. Exception calling "Remove" with "0" argument(s): "The given key was not present in the dictionary." PM>

EF Core Version: 2.0.1

When you're adding or removing a migration, the application is build. So, most likely you have a collection where you're trying to remove an item with a wrong key and the compiler goes through that piece of code while removing the migration.

The Application is always building when a migration is added to the Project as mentioned in the previous answers.

This one is not actually a Solution, its more a workaround which is working for me at most.

Try to remove your Migration mit following Command

Remove-Migration NameOfMigration

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM