using SqlSugar;
using System.Collections.Concurrent;
namespace LFlow.Base.Utils;
///
/// CodeFirst
///
public static class CodeFirst
{
///
/// 类型集合
///
private static readonly ConcurrentBag _types = [];
///
/// 添加类型
///
///
public static void AddType(Type type)
{
_types.Add(type);
}
///
/// 初始化表
///
internal static void InitTable()
{
var logger = App.GetService()!;
var db = App.GetService()!;
foreach (var type in _types)
{
db.CodeFirst.InitTables(type);
logger.Information($"Init table {type.Name} success");
}
}
///
/// 初始化数据库种子
///
internal static void InitDBSeed()
{
//TODO: Seed data
}
}