mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-21 02:58:05 +08:00
48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
![]() |
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
|
|||
|
}
|
|||
|
}
|
|||
|
}
|