dbProvider.CodeFirst.InitTables(entityType) 异常
生成表格时:使用的默认的数据库 Sqlite dbProvider.CodeFirst.InitTables(entityType); entityType为SysCodeGenConfig 时 报错了
System.Reflection.TargetInvocationException
HResult=0x80131604
Message=Exception has been thrown by the target of an invocation.
Source=System.Private.CoreLib
StackTrace:
在 System.RuntimeMethodHandle.InvokeMethod(Object target, Span1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions) 在 System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) 在 Microsoft.Extensions.DependencyInjection.AppServiceCollectionExtensions.AddStartups(IServiceCollection services) 在 Microsoft.Extensions.DependencyInjection.AppServiceCollectionExtensions.AddApp(IServiceCollection services, Action1 configure)
在 Furion.InternalApp.<>c.<ConfigureApplication>b__5_1(WebHostBuilderContext hostContext, IServiceCollection services)
在 Microsoft.AspNetCore.Builder.ConfigureWebHostBuilder.ConfigureServices(Action2 configureServices) 在 Furion.InternalApp.ConfigureApplication(IWebHostBuilder builder, IHostBuilder hostBuilder) 在 Microsoft.AspNetCore.Builder.AppWebApplicationBuilderExtensions.Inject(WebApplicationBuilder webApplicationBuilder, Action2 configure)
在 System.Serve.Run(RunOptions options, String urls)
在 Program.<Main>$(String[] args) 在 D:\Project\Admin.NET\Admin.NET\Admin.NET.Web.Entry\Program.cs 中: 第 10 行
此异常最初是在此调用堆栈中引发的: [外部代码]
内部异常 1: InvalidOperationException: Method may only be called on a Type for which Type.IsGenericParameter is true.
if (config.TableSettings.EnableInitTable) { var entityTypes = App.EffectiveTypes.Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass && u.IsDefined(typeof(SugarTable), false)) .WhereIF(config.TableSettings.EnableIncreTable, u => u.IsDefined(typeof(IncreTableAttribute), false)).ToList();
if (config.ConfigId == SqlSugarConst.MainConfigId) // 默认库(有系统表特性、没有日志表和租户表特性)
entityTypes = entityTypes.Where(u => u.GetCustomAttributes<SysTableAttribute>().Any() || (!u.GetCustomAttributes<LogTableAttribute>().Any() && !u.GetCustomAttributes<TenantAttribute>().Any())).ToList();
else if (config.ConfigId == SqlSugarConst.LogConfigId) // 日志库
entityTypes = entityTypes.Where(u => u.GetCustomAttributes<LogTableAttribute>().Any()).ToList();
else
entityTypes = entityTypes.Where(u => u.GetCustomAttribute<TenantAttribute>()?.configId.ToString() == config.ConfigId).ToList(); // 自定义的库
foreach (var entityType in entityTypes)
{
if (entityType.GetCustomAttribute<SplitTableAttribute>() == null)
dbProvider.CodeFirst.InitTables(entityType);
else
dbProvider.CodeFirst.SplitTables().InitTables(entityType);
}
}