简体   繁体   English

使用“0”参数调用“删除”的异常:“字典中不存在给定的键

[英]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.我已经使用Add-Migration添加了一个Add-Migration ,现在如果我运行Remove-Migration ,它会恢复迁移并成功删除生成的迁移文件,但也会在包管理器控制台中给出错误。 I could not figure out the exact reason behind it and side effect of it.我无法弄清楚其背后的确切原因及其副作用。 Is this EF Core bug?这是 EF Core 的错误吗?

Package Manager Output:包管理器输出:

PM> Remove-Migration Removing migration '20180320052521_testMigration'. PM> Remove-Migration 删除迁移“20180320052521_testMigration”。 Reverting model snapshot.恢复模型快照。 Done.完毕。 Exception calling "Remove" with "0" argument(s): "The given key was not present in the dictionary."使用“0”参数调用“Remove”的异常:“字典中不存在给定的键。” PM>下午>

EF Core Version: 2.0.1 EF 核心版本: 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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