From 76508953346cbcc2d7191e5c26f83d5beec2695c Mon Sep 17 00:00:00 2001 From: zuohuaijun Date: Tue, 15 Apr 2025 17:25:49 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=98=8E=E4=BB=A3=E7=A0=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs b/Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs index f7027276..8bafc8ea 100644 --- a/Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs +++ b/Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs @@ -361,11 +361,11 @@ public static class SqlSugarSetup { SqlSugarScopeProvider dbProvider = db.GetConnectionScope(config.ConfigId); - // 判断系统是否是第一次启动,是则强制初始化数据库和种子数据 - bool isfirst = dbProvider.CurrentConnectionConfig.ConfigId.ToString() == SqlSugarConst.MainConfigId && !dbProvider.DbMaintenance.IsAnyTable(nameof(SysConfig)); + // 若第一次启动系统则强制初始化数据库表和种子数据 + bool isFirstRun = dbProvider.CurrentConnectionConfig.ConfigId.ToString() == SqlSugarConst.MainConfigId && !dbProvider.DbMaintenance.IsAnyTable(nameof(SysConfig)); // 初始化/创建数据库 - if (config.DbSettings.EnableInitDb || isfirst) + if (config.DbSettings.EnableInitDb || isFirstRun) { Log.Information($"初始化数据库 {config.DbType} - {config.ConfigId} - {config.ConnectionString}"); if (config.DbType != SqlSugar.DbType.Oracle) dbProvider.DbMaintenance.CreateDatabase(); @@ -375,7 +375,7 @@ public static class SqlSugarSetup var (startups, oldVerion, currentVersion) = BeforeInitTable(dbProvider, config); // 初始化表结构 - if (config.TableSettings.EnableInitTable || isfirst) + if (config.TableSettings.EnableInitTable || isFirstRun) { Log.Information($"初始化表结构 {config.DbType} - {config.ConfigId}"); var entityTypes = App.EffectiveTypes.Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass && u.IsDefined(typeof(SugarTable), false)) @@ -413,7 +413,7 @@ public static class SqlSugarSetup } // 初始化种子数据 - if (config.SeedSettings.EnableInitSeed || isfirst) InitSeedData(db, config); + if (config.SeedSettings.EnableInitSeed || isFirstRun) InitSeedData(db, config); // 初始化种子数据之后——系统版本号 AfterInitSeed(dbProvider, config, startups, oldVerion, currentVersion);