我不小心删除了我的数据库表,我需要找回它们。我试过运行 update-database
,但我只得到:
Cannot find the object "dbo.ArticleComments" because it does not exist or you do not have permissions.
我还尝试使用迁移名称运行 Update-Database -TargetMigration:"name_of_migration"
但结果是:
Cannot find the object "dbo.ArticleComments" because it does not exist or you do not have permissions.
我需要知道如何取回我的数据库表及其列(是否为空我不在乎)
最佳答案
这可能是您的情况的问题。
检查这个有问题的表dbo.ArticleComments
。如果您重命名
或删除
它,那么它会给出上述类型的错误。 B'cos 当您创建那里的旧迁移脚本时。现在它不在那里。当您尝试运行相同的旧迁移脚本时,现在该表不在您的 DbSet
上或具有不同的名称.
解决方案:
如果是这种情况,那么您必须手动编辑迁移文件以反射(reflect)当前表的更改。
关于sql - EF Code First回滚数据库表设计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39316124/