EF Code First 回滚数据库 table 设计
EF Code First rollback database table design
我不小心删除了我的数据库表,我需要找回它们。我试过 运行 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.
我需要知道如何取回我的数据库表及其列(是否为空我不在乎)
这可能是您的情况的问题。
检查这个有问题的 table dbo.ArticleComments
。如果你 renamed
或 deleted
它,那么它会给出以上那种 error.B'cos当您创建 there.Now 的旧迁移脚本时,它不是 there.When 您尝试 运行 相同的旧迁移脚本,现在 table 不在您的 DbSet
或具有不同的名称。
解法:
如果是这种情况,则您必须手动编辑迁移文件以反映当前的 table 更改。
我不小心删除了我的数据库表,我需要找回它们。我试过 运行 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.
我需要知道如何取回我的数据库表及其列(是否为空我不在乎)
这可能是您的情况的问题。
检查这个有问题的 table dbo.ArticleComments
。如果你 renamed
或 deleted
它,那么它会给出以上那种 error.B'cos当您创建 there.Now 的旧迁移脚本时,它不是 there.When 您尝试 运行 相同的旧迁移脚本,现在 table 不在您的 DbSet
或具有不同的名称。
解法:
如果是这种情况,则您必须手动编辑迁移文件以反映当前的 table 更改。