我使用的代码首先创建一个表。
我创建的类,映射文件和授权的NuGet附加转移命令,然后更新数据库命令
然后,我改变了类,并像一个白痴删除的表。
我删除了迁移类文件
我发出一个附加迁移命令
当我发出update-database命令我碰到下面的错误:
System.Data.SqlClient.SqlException(0x80131904):找不到对象“dbo.CorrectiveActionPlan”,因为它不存在或您没有权限。 在System.Data.SqlClient.SqlConnection.OnError(SqlException异常,布尔breakConnection,动作
1 wrapCloseInAction) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action
1个wrapCloseInAction)在System.Data.SqlClient.TdsParser .ThrowExceptionAndWarning(TdsParserStateObject stateObj,布尔callerHasConnectionLock,布尔asyncClose)在System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior,SqlCommand的cmdHandler,SqlDataReader的数据流,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj,布尔逻辑dataReady)在System.Data.SqlClient.SqlCommand。 RunExecuteNonQueryTds(字符串方法名,布尔异步,的Int32超时)在System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at System.Data.Entity.Migrations.DbMigrator.ExecuteSql(DbTransaction transaction, MigrationStatement migrationStatement) at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ExecuteSql(DbTransaction transaction, MigrationStatement migrationStatement) at System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable
1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at System.Data.Entity.Migrations.DbMigrator.ExecuteSql(DbTransaction transaction, MigrationStatement migrationStatement) at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ExecuteSql(DbTransaction transaction, MigrationStatement migrationStatement) at System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable
1个migrationStatements)在System.Data.Entity的.Migrations.Infrastructure.MigratorBase.ExecuteStatements(IEnumerable的1 migrationStatements) at System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String migrationId, XDocument targetModel, IEnumerable
在System.Data.Entity.Migrations 1个操作,布尔降级,布尔自动) .DbMigrator.ApplyMigration(DbMigration迁移,DbMigration lastMigration)在System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ApplyMigration(DbMigration迁移,DbMigration lastMigration)在System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable的1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable1 pendingMigrations, String targetMigrationId, String lastMigrationId)
1个pendingMigrations,字符串targetMigrationId,字符串lastMigrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable
在System.Data.Entity.Migrations.DbMigrator.Update(字符串targetMigration)在System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(字符串targetMigration)在System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.RunCore ()在System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()ClientConnectionId:a6e92a35-cc9e-4867-97a5-0a274081d853找不到对象“dbo.CorrectiveActionPlan”,因为它不存在,或者你没有权限。
如何强制EF重建表?