feat: 调整初始化表输出提示时机

当执行初始化表比较慢时,完成时再输出可以更直观显示执行完成情况
This commit is contained in:
写意 2025-05-06 22:39:52 +08:00
parent 4e320c7279
commit 85f6001175

View File

@ -394,9 +394,6 @@ public static class SqlSugarSetup
int taskIndex = 0, entityTypeCount = entityTypes.Count; int taskIndex = 0, entityTypeCount = entityTypes.Count;
var taskList = entityTypes.Select(entityType => Task.Run(() => var taskList = entityTypes.Select(entityType => Task.Run(() =>
{ {
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"初始化表 {entityType,-64} ({config.ConfigId} - {Interlocked.Increment(ref taskIndex):D003}/{entityTypeCount:D003})");
// 将不存在实体中的字段改为可空 // 将不存在实体中的字段改为可空
var entityInfo = dbProvider.EntityMaintenance.GetEntityInfo(entityType); var entityInfo = dbProvider.EntityMaintenance.GetEntityInfo(entityType);
var dbColumnInfos = dbProvider.DbMaintenance.GetColumnInfosByTableName(entityInfo.DbTableName) ?? []; var dbColumnInfos = dbProvider.DbMaintenance.GetColumnInfosByTableName(entityInfo.DbTableName) ?? [];
@ -410,6 +407,9 @@ public static class SqlSugarSetup
dbProvider.CodeFirst.InitTables(entityType); dbProvider.CodeFirst.InitTables(entityType);
else else
dbProvider.CodeFirst.SplitTables().InitTables(entityType); dbProvider.CodeFirst.SplitTables().InitTables(entityType);
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"初始化表 {entityType,-64} ({config.ConfigId} - {Interlocked.Increment(ref taskIndex):D003}/{entityTypeCount:D003})");
})); }));
Task.WaitAll(taskList.ToArray()); Task.WaitAll(taskList.ToArray());
} }