From 0086215f2ed9cb7bb57fe475959d7d4a5faabfd8 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Tue, 20 Feb 2024 16:48:07 +0800 Subject: [PATCH] =?UTF-8?q?Optimize=20=20=E9=87=91=E4=BB=93R3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Kdbndp/DbMaintenance/KdbndpDbMaintenance.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Src/Asp.NetCore2/SqlSugar/Realization/Kdbndp/DbMaintenance/KdbndpDbMaintenance.cs b/Src/Asp.NetCore2/SqlSugar/Realization/Kdbndp/DbMaintenance/KdbndpDbMaintenance.cs index b1bc6c86e..86ef41cea 100644 --- a/Src/Asp.NetCore2/SqlSugar/Realization/Kdbndp/DbMaintenance/KdbndpDbMaintenance.cs +++ b/Src/Asp.NetCore2/SqlSugar/Realization/Kdbndp/DbMaintenance/KdbndpDbMaintenance.cs @@ -419,6 +419,15 @@ WHERE tgrelid = '" + tableName + "'::regclass"); IsAutoCloseConnection = true, ConnectionString = connection }); + if (newDb.Ado.IsValidConnection() == false) + { + newDb = new SqlSugarClient(new ConnectionConfig() + { + DbType = this.Context.CurrentConnectionConfig.DbType, + IsAutoCloseConnection = true, + ConnectionString = this.Context.CurrentConnectionConfig.ConnectionString.Replace(oldDatabaseName, "TEST") + }); + } if (!GetDataBaseList(newDb).Any(it => it.Equals(databaseName, StringComparison.CurrentCultureIgnoreCase))) { newDb.Ado.ExecuteCommand(string.Format(CreateDataBaseSql, this.SqlBuilder.SqlTranslationLeft+databaseName+this.SqlBuilder.SqlTranslationRight, databaseDirectory));