2025-10-21 13:38:23 +08:00

36 lines
1.2 KiB
C#

using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SqlSugar.IOC;
using RIZO.Mall.Model;
namespace RIZO.Mall
{
/// <summary>
/// 初始化表
/// </summary>
public static class InitMallTable
{
public static void InitDb(this IServiceCollection services, IWebHostEnvironment environment)
{
var db = DbScoped.SugarScope.GetConnection("0");
var options = App.OptionsSetting;
if (!options.InitDb) return;
if (environment.IsDevelopment())
{
db.CodeFirst.InitTables(typeof(Product));
db.CodeFirst.InitTables(typeof(ProductSpec));
db.CodeFirst.InitTables(typeof(Skus));
db.CodeFirst.InitTables(typeof(Category));
db.CodeFirst.InitTables(typeof(Brand));
db.CodeFirst.InitTables(typeof(OMSOrder));
db.CodeFirst.InitTables(typeof(OMSOrderItem));
db.CodeFirst.InitTables(typeof(MMSUserAddress));
db.CodeFirst.InitTables(typeof(SpecTemplate));
}
}
}
}