From edc06f461be90c030cef8c20f7b6744a630c2dc3 Mon Sep 17 00:00:00 2001 From: FunCoder Date: Tue, 29 Apr 2025 17:25:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A4=E6=96=AD=E7=AC=AC=E4=B8=80=E6=AC=A1?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=EF=BC=8C=E5=8A=A0=E4=B8=8Atry-catch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs b/Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs index 361645eb..ca5c3313 100644 --- a/Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs +++ b/Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs @@ -362,7 +362,9 @@ public static class SqlSugarSetup SqlSugarScopeProvider dbProvider = db.GetConnectionScope(config.ConfigId); // 若第一次启动系统则强制初始化数据库表和种子数据 - bool isFirstRun = dbProvider.CurrentConnectionConfig.ConfigId.ToString() == SqlSugarConst.MainConfigId && !dbProvider.DbMaintenance.IsAnyTable(dbProvider.EntityMaintenance.GetTableName(typeof(SysConfig))); + bool isFirstRun = false; + try { isFirstRun = dbProvider.CurrentConnectionConfig.ConfigId.ToString() == SqlSugarConst.MainConfigId && !dbProvider.DbMaintenance.IsAnyTable(dbProvider.EntityMaintenance.GetTableName(typeof(SysConfig))); } + catch { isFirstRun = true; } // 初始化/创建数据库 if (config.DbSettings.EnableInitDb || isFirstRun)