Files
SqlSugar/Src/Asp.NetCore2/MySqlTest/UserTestCases/UnitTest/Unitdfasdyss.cs

48 lines
1.5 KiB
C#
Raw Normal View History

2025-07-31 13:05:13 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest
{
using System.Reflection;
using SqlSugar;
internal class Unitsdfasfasa
{
public static void Init()
{
var db = NewUnitTest.Db;
var types = Assembly.GetExecutingAssembly().GetTypes()
.Where(type => !type.IsGenericType)
.Where(s=>s.Namespace== "WebApplication4")
.Where(type => !type.IsInterface)
.Where(type => !type.IsAbstract)
.Where(type => IntrospectionExtensions.GetTypeInfo(type).IsClass)
.Where(type => type.GetCustomAttribute<SqlSugar.SugarTable>() != null)
.ToArray();
#region
//var diffString2 = db.CodeFirst.GetDifferenceTables(types).ToDiffString();
#endregion
#region
foreach (var type in types)
{
try
{
var diffString = db.CodeFirst.GetDifferenceTables(type).ToDiffString();
db.CodeFirst.InitTables(type);
}
catch (Exception ex)
{
Console.WriteLine($"type = {type.Name} 错误: {ex}");
}
}
#endregion
}
}
}