设置错误-数据库中已经存在一个名为“ AbpAuditLogs”的对象

时间:2018-08-23 15:55:13

标签: c# entity-framework aspnetboilerplate

无论我下载哪种解决方案(预发行版或稳定版),我都继续遇到相同的错误。这是我要执行的步骤。

  1. 在Visual Studio Community 2017 v 15.5.3中打开
  2. 构建以还原NuGet软件包
  3. 将Web项目设置为启动项目
  4. 在web.config连接字符串中,将“ Server = Localhost”更改为“ Server =。\ SQLExpress”
  5. 在程序包管理器控制台中,选择EntityFramework作为默认项目
  6. 运行更新数据库

出现以下错误:

应用显式迁移:[201707261347311_Initial_Migration,201710131316266_UpgradedTo_ABP_3.1,201801311121458_Modified_Authorization_Entities,201803261403237_Upgraded_To_Abp_v3_5,201807270535111_Updated_ABP,201807271154374_Up。 应用显式迁移:201707261347311_Initial_Migration。 应用显式迁移:201710131316266_UpgradedTo_ABP_3.1。 应用显式迁移:201801311121458_Modified_Authorization_Entities。 应用显式迁移:201803261403237_Upgraded_To_Abp_v3_5。 应用显式迁移:201807270535111_Updated_ABP。 System.Data.SqlClient.SqlException(0x80131904):数据库中已经有一个名为“ AbpAuditLogs”的对象。    在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,布尔调用方HasConnectionLock,布尔asyncClose)    在System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior,SqlCommand cmdHandler,SqlDataReader dataStream,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj,Boolean和dataReady)    在System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(字符串methodName,布尔异步,Int32超时,布尔asyncWrite)    在System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource 1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<NonQuery>b__0(DbCommand t, DbCommandInterceptionContext 1c)    执行System.Data.Entity.Infrastructure.Interception.InternalDispatcher 1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func 3操作,执行TInterceptionContext拦截上下文,执行Action 3 executing, Action 3)    在System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.NonQuery(DbCommand命令,DbCommandInterceptionContext拦截上下文)    在System.Data.Entity.Internal.InterceptableDbCommand.ExecuteNonQuery()    在System.Data.Entity.Migrations.DbMigrator.ExecuteSql(MigrationStatement migrationStatement,DbConnection连接,DbTransaction事务,DbInterceptionContext拦截上下文)    在System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ExecuteSql(MigrationStatement migrationStatement,DbConnection连接,DbTransaction事务,DbInterceptionContext拦截上下文)    在System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable 1 migrationStatements, DbConnection connection, DbTransaction transaction, DbInterceptionContext interceptionContext) at System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsWithinTransaction(IEnumerable 1迁移声明,DbTransaction事务,DbInterceptionContext拦截上下文)    在System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsWithinNewTransaction(IEnumerable 1 migrationStatements, DbConnection connection, DbInterceptionContext interceptionContext) at System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable 1 migrationStatements,DbConnection连接,DbInterceptionContext拦截上下文中)    在System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable 1 migrationStatements, DbConnection connection) at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClass32.<ExecuteStatements>b__30() at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass1.<Execute>b__0() at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func 1操作)处    在System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(操作操作)    在System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable 1 migrationStatements, DbTransaction existingTransaction) 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, VersionedModel targetModel, IEnumerable 1个操作,IEnumerable 1 systemOperations, Boolean downgrading, Boolean auto) at System.Data.Entity.Migrations.DbMigrator.ApplyMigration(DbMigration migration, DbMigration lastMigration) at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ApplyMigration(DbMigration migration, DbMigration lastMigration) at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable 1个未决迁移,字符串targetMigrationId,字符串lastMigrationId)处    在System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1endingMigrations,String targetMigrationId,String lastMigrationId)    在System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration)    在System.Data.Entity.Migrations.DbMigrator。<> c__DisplayClasse.b__d()    在System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(操作mustSucceedToKeepDatabase)    在System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(操作mustSucceedToKeepDatabase)处    在System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)    在System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration)    在System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.RunCore()    在System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run() ClientConnectionId:f703c413-5ffa-4dfe-bee8-4641d26e1fce 错误号:2714,状态:6,类别:16 数据库中已经有一个名为“ AbpAuditLogs”的对象。

正在创建数据库,但我认为上一次迁移201807270535111_Updated_ABP导致了冲突。

1 个答案:

答案 0 :(得分:0)

您可以删除所有迁移并添加新的“ Initial Migration”。

参考:https://github.com/aspnetboilerplate/module-zero-template/pull/140