添加codeFirst功能

This commit is contained in:
陈淳
2022-10-18 18:01:16 +08:00
parent dab4a092d9
commit ab8cdd88b9
25 changed files with 161 additions and 121 deletions

View File

@@ -272,7 +272,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
public Result SeedDb()
{
var rep = _iUserService._repository;
return Result.Success().SetStatus(DbSeedExtend.Invoer(rep._Db));
return Result.Success().SetStatus(DbSeedExtend.DataInvoer(rep._Db));
}
/// <summary>

View File

@@ -43,9 +43,6 @@
<None Update="public.pem">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="yi-sqlsugar-dev.db">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@@ -1,5 +1,5 @@
{
"StartUrl": "http://localohost:19001",
"StartUrl": "http://*:19001",
"Logging": {
"LogLevel": {
"Default": "Information",
@@ -12,10 +12,13 @@
"SqlLog_Enable": false,
"Consul_Enabled": false,
"DbCodeFirst_Enabled": false,
"DbSeed_Enabled": false,
"Apollo_Enabled": false,
"HealthCheck_Enabled": false,
"RabbitMQ_Enabled": false,
"Redis_Enabled": false,
"RedisSeed_Enabled": false,
"Kafka_Enabled": false,
"ElasticSeach_Enabled": false,
"MutiDB_Enabled": false,
@@ -23,19 +26,16 @@
"CAP_Enabled": false,
"CAPDashboard_Enabled": false,
"DbSeed_Enabled": true,
"RedisSeed_Enabled": false,
"Cors_Enabled": true,
"DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle" ],
"DbSelect": "Sqlite",
"DbConn": {
"WriteUrl": "DataSource=yi-sqlsugar-dev.db",
//"WriteUrl": "server=119.91.207.67;port=3306;database=yi-sqlsugar-dev;user id=root;password=Qz52013142020.",
//"WriteUrl": "[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]",
"ReadUrl": [
"server=119.91.207.67;port=3306;database=yi-sqlsugar-dev;user id=root;password=Qz52013142020.",
"server=119.91.207.67;port=3306;database=yi-sqlsugar-dev;user id=root;password=Qz52013142020.",
"server=119.91.207.67;port=3306;database=yi-sqlsugar-dev;user id=root;password=Qz52013142020."
"server=[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]",
"server=[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]",
"server=[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]"
]
},
"JwtAuthorize": {
@@ -44,39 +44,39 @@
"PolicyName": "permission",
"DefaultScheme": "Bearer",
"IsHttps": false,
"Expiration": 30,
"Expiration": 300,
"ReExpiration": 3000
},
"RedisConnOptions": {
"Host": "118.195.191.41",
"Host": "[xxxx]",
"Prot": 6379,
"DB": 1,
"Password": "Qz52013142020."
"Password": "[xxxx]"
},
"RabbitConn": {
"HostName": "118.195.191.41",
"UserName": "cc",
"Password": "cc",
"HostName": "[xxxx]",
"UserName": "[xxxx]",
"Password": "[xxxx]",
"Port": 5672
},
"ElasticSeachConn": {
"Url": "https://es-4zakkyyn.public.tencentelasticsearch.com:9200",
"IndexName": "yies",
"UserName": "elastic",
"PassWord": "Qz52013142020."
"Url": "[xxxx]",
"IndexName": "[xxxx]",
"UserName": "[xxxx]",
"PassWord": "[xxxx]"
},
"KafkaOptions": {
"BrokerList": "192.168.3.230:9092",
"TopicName": "kafkalog"
"BrokerList": "[xxxx]",
"TopicName": "[xxxx]"
},
"ConsulClientOption": {
"IP": "118.195.191.41",
"Port": "8500",
"Datacenter": "dc1"
"IP": "[xxxx]",
"Port": "[xxxx]",
"Datacenter": "[xxxx]"
},
"ConsulRegisterOption": {
"IP": "118.195.191.41",
"Port": "19005",
"IP": "[xxxx]",
"Port": "19001",
"GroupName": "ApiMicroservice",
"HealthCheckUrl": "/Health",
"Interval": 10,
@@ -85,10 +85,10 @@
"Tag": "13"
},
"SMS": {
"ID": "LTAI5tJvjPaXCyyPMfXLNbVA",
"Secret": "fLQv7jjj57fUKLFK8REeAQPFVDjUYn",
"Sign": "JiftCC",
"Template": "SMS_221640732"
"ID": "[xxxx]",
"Secret": "[xxxx]",
"Sign": "[xxxx]",
"Template": "[xxxx]"
},
"IPLibraryServiceUrl": "http://gRPCIPLibraryService"
}

View File

@@ -12,6 +12,7 @@
"SqlLog_Enable": false,
"Consul_Enabled": false,
"DbCodeFirst_Enabled": false,
"DbSeed_Enabled": false,
"Apollo_Enabled": false,
"HealthCheck_Enabled": false,
@@ -27,23 +28,24 @@
"Cors_Enabled": true,
"DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle" ],
"DbSelect": "Mysql",
"Pan": {
"ZipPath": "D:/AppWeb/test/zip"
},
"DbSelect": "Sqlite",
"DbConn": {
"WriteUrl": "server=[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]",
"WriteUrl": "DataSource=yi-sqlsugar-dev.db",
//"WriteUrl": "[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]",
"ReadUrl": [
"server=[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]",
"server=[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]",
"server=[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]"
]
},
"JWTTokenOptions": {
"Audience": "http://localhost:7000",
"Issuer": "http://localhost:7000",
"SecurityKey": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDI2a2EJ7m872v0afyoSDJT2o1+SitIeJSWtLJU8/Wz2m7gStexajkeD+Lka6DSTy8gt9UwfgVQo6uKjVLG5Ex7PiGOODVqAEghBuS7JzIYU5RvI543nNDAPfnJsas96mSA7L/mD7RTE2drj6hf3oZjJpMPZUQI/B1Qjb5H3K3PNwIDAQAB"
"JwtAuthorize": {
"Issuer": "cc",
"Audience": "cc",
"PolicyName": "permission",
"DefaultScheme": "Bearer",
"IsHttps": false,
"Expiration": 300,
"ReExpiration": 3000
},
"RedisConnOptions": {
"Host": "[xxxx]",

View File

@@ -12,6 +12,7 @@
"SqlLog_Enable": false,
"Consul_Enabled": false,
"DbCodeFirst_Enabled": false,
"DbSeed_Enabled": false,
"Apollo_Enabled": false,
"HealthCheck_Enabled": false,

View File

@@ -22,12 +22,12 @@ namespace Yi.Framework.Model.Models
/// 文章标题
///</summary>
[SugarColumn(ColumnName="Title" )]
public string Title { get; set; }
public string? Title { get; set; }
/// <summary>
/// 文章内容
///</summary>
[SugarColumn(ColumnName="Content" )]
public string Content { get; set; }
public string? Content { get; set; }
/// <summary>
/// 用户id
///</summary>
@@ -72,7 +72,7 @@ namespace Yi.Framework.Model.Models
/// 描述
///</summary>
[SugarColumn(ColumnName="Remark" )]
public string Remark { get; set; }
public string? Remark { get; set; }
/// <summary>
/// 图片列表
///</summary>

View File

@@ -22,22 +22,22 @@ namespace Yi.Framework.Model.Models
/// 配置名称
///</summary>
[SugarColumn(ColumnName="ConfigName" )]
public string ConfigName { get; set; }
public string? ConfigName { get; set; }
/// <summary>
/// 配置键
///</summary>
[SugarColumn(ColumnName="ConfigKey" )]
public string ConfigKey { get; set; }
public string? ConfigKey { get; set; }
/// <summary>
/// 配置值
///</summary>
[SugarColumn(ColumnName="ConfigValue" )]
public string ConfigValue { get; set; }
public string? ConfigValue { get; set; }
/// <summary>
/// 配置类别
///</summary>
[SugarColumn(ColumnName="ConfigType" )]
public string ConfigType { get; set; }
public string? ConfigType { get; set; }
/// <summary>
/// 创建者
///</summary>
@@ -77,6 +77,6 @@ namespace Yi.Framework.Model.Models
/// 描述
///</summary>
[SugarColumn(ColumnName="Remark" )]
public string Remark { get; set; }
public string? Remark { get; set; }
}
}

View File

@@ -22,17 +22,17 @@ namespace Yi.Framework.Model.Models
/// 部门名称
///</summary>
[SugarColumn(ColumnName="DeptName" )]
public string DeptName { get; set; }
public string? DeptName { get; set; }
/// <summary>
/// 部门编码
///</summary>
[SugarColumn(ColumnName="DeptCode" )]
public string DeptCode { get; set; }
public string? DeptCode { get; set; }
/// <summary>
/// 负责人
///</summary>
[SugarColumn(ColumnName="Leader" )]
public string Leader { get; set; }
public string? Leader { get; set; }
/// <summary>
/// 父级id
///</summary>
@@ -77,6 +77,6 @@ namespace Yi.Framework.Model.Models
/// 描述
///</summary>
[SugarColumn(ColumnName="Remark" )]
public string Remark { get; set; }
public string? Remark { get; set; }
}
}

View File

@@ -22,12 +22,12 @@ namespace Yi.Framework.Model.Models
/// 字典名称
///</summary>
[SugarColumn(ColumnName="DictName" )]
public string DictName { get; set; }
public string? DictName { get; set; }
/// <summary>
/// 字典类型
///</summary>
[SugarColumn(ColumnName="DictType" )]
public string DictType { get; set; }
public string? DictType { get; set; }
/// <summary>
/// 创建者
///</summary>
@@ -67,6 +67,6 @@ namespace Yi.Framework.Model.Models
/// 描述
///</summary>
[SugarColumn(ColumnName="Remark" )]
public string Remark { get; set; }
public string? Remark { get; set; }
}
}

View File

@@ -22,17 +22,17 @@ namespace Yi.Framework.Model.Models
/// 字典类型
///</summary>
[SugarColumn(ColumnName="DictType" )]
public string DictType { get; set; }
public string? DictType { get; set; }
/// <summary>
/// 字典标签
///</summary>
[SugarColumn(ColumnName="DictLabel" )]
public string DictLabel { get; set; }
public string? DictLabel { get; set; }
/// <summary>
/// 字典值
///</summary>
[SugarColumn(ColumnName="DictValue" )]
public string DictValue { get; set; }
public string? DictValue { get; set; }
/// <summary>
/// 是否为该类型的默认值
///</summary>
@@ -77,16 +77,16 @@ namespace Yi.Framework.Model.Models
/// 描述
///</summary>
[SugarColumn(ColumnName="Remark" )]
public string Remark { get; set; }
public string? Remark { get; set; }
/// <summary>
/// tag类型
///</summary>
[SugarColumn(ColumnName="ListClass" )]
public string ListClass { get; set; }
public string? ListClass { get; set; }
/// <summary>
/// tagClass
///</summary>
[SugarColumn(ColumnName="CssClass" )]
public string CssClass { get; set; }
public string? CssClass { get; set; }
}
}

View File

@@ -22,7 +22,7 @@ namespace Yi.Framework.Model.Models
/// 文件类型
///</summary>
[SugarColumn(ColumnName="FileType" )]
public string FileType { get; set; }
public string? FileType { get; set; }
/// <summary>
/// 文件大小
///</summary>
@@ -32,12 +32,12 @@ namespace Yi.Framework.Model.Models
/// 文件名
///</summary>
[SugarColumn(ColumnName="FileName" )]
public string FileName { get; set; }
public string? FileName { get; set; }
/// <summary>
/// 文件路径
///</summary>
[SugarColumn(ColumnName="FilePath" )]
public string FilePath { get; set; }
public string? FilePath { get; set; }
/// <summary>
/// 创建者
///</summary>
@@ -77,6 +77,6 @@ namespace Yi.Framework.Model.Models
/// 描述
///</summary>
[SugarColumn(ColumnName="Remark" )]
public string Remark { get; set; }
public string? Remark { get; set; }
}
}

View File

@@ -43,7 +43,7 @@ namespace Yi.Framework.Model.Models
/// 消息
///</summary>
[SugarColumn(ColumnName="Message" )]
public string Message { get; set; }
public string? Message { get; set; }
/// <summary>
/// 排序字段
///</summary>
@@ -53,6 +53,6 @@ namespace Yi.Framework.Model.Models
/// 描述
///</summary>
[SugarColumn(ColumnName="Remark" )]
public string Remark { get; set; }
public string? Remark { get; set; }
}
}

View File

@@ -22,32 +22,32 @@ namespace Yi.Framework.Model.Models
/// 登录用户
///</summary>
[SugarColumn(ColumnName="LoginUser" )]
public string LoginUser { get; set; }
public string? LoginUser { get; set; }
/// <summary>
/// 登录地点
///</summary>
[SugarColumn(ColumnName="LoginLocation" )]
public string LoginLocation { get; set; }
public string? LoginLocation { get; set; }
/// <summary>
/// 登录Ip
///</summary>
[SugarColumn(ColumnName="LoginIp" )]
public string LoginIp { get; set; }
public string? LoginIp { get; set; }
/// <summary>
/// 浏览器
///</summary>
[SugarColumn(ColumnName="Browser" )]
public string Browser { get; set; }
public string? Browser { get; set; }
/// <summary>
/// 操作系统
///</summary>
[SugarColumn(ColumnName="Os" )]
public string Os { get; set; }
public string? Os { get; set; }
/// <summary>
/// 登录信息
///</summary>
[SugarColumn(ColumnName="LogMsg" )]
public string LogMsg { get; set; }
public string? LogMsg { get; set; }
/// <summary>
/// 创建者
///</summary>
@@ -82,7 +82,7 @@ namespace Yi.Framework.Model.Models
/// 描述
///</summary>
[SugarColumn(ColumnName="Remark" )]
public string Remark { get; set; }
public string? Remark { get; set; }
/// <summary>
/// 是否删除
///</summary>

View File

@@ -23,7 +23,7 @@ namespace Yi.Framework.Model.Models
///
///</summary>
[SugarColumn(ColumnName="MenuName" )]
public string MenuName { get; set; }
public string? MenuName { get; set; }
/// <summary>
///
///</summary>
@@ -33,7 +33,7 @@ namespace Yi.Framework.Model.Models
///
///</summary>
[SugarColumn(ColumnName="PermissionCode" )]
public string PermissionCode { get; set; }
public string? PermissionCode { get; set; }
/// <summary>
///
///</summary>
@@ -73,12 +73,12 @@ namespace Yi.Framework.Model.Models
/// 菜单图标
///</summary>
[SugarColumn(ColumnName="MenuIcon" )]
public string MenuIcon { get; set; }
public string? MenuIcon { get; set; }
/// <summary>
/// 菜单组件路由
///</summary>
[SugarColumn(ColumnName="Router" )]
public string Router { get; set; }
public string? Router { get; set; }
/// <summary>
/// 是否为外部链接
///</summary>
@@ -103,16 +103,16 @@ namespace Yi.Framework.Model.Models
/// 描述
///</summary>
[SugarColumn(ColumnName="Remark" )]
public string Remark { get; set; }
public string? Remark { get; set; }
/// <summary>
/// 组件路径
///</summary>
[SugarColumn(ColumnName="Component" )]
public string Component { get; set; }
public string? Component { get; set; }
/// <summary>
/// 路由参数
///</summary>
[SugarColumn(ColumnName="Query" )]
public string Query { get; set; }
public string? Query { get; set; }
}
}

View File

@@ -22,7 +22,7 @@ namespace Yi.Framework.Model.Models
/// 操作模块
///</summary>
[SugarColumn(ColumnName="Title" )]
public string Title { get; set; }
public string? Title { get; set; }
/// <summary>
/// 操作类型
///</summary>
@@ -32,7 +32,7 @@ namespace Yi.Framework.Model.Models
/// 请求方法
///</summary>
[SugarColumn(ColumnName="RequestMethod" )]
public string RequestMethod { get; set; }
public string? RequestMethod { get; set; }
/// <summary>
/// 操作人员
///</summary>
@@ -42,27 +42,27 @@ namespace Yi.Framework.Model.Models
/// 操作Ip
///</summary>
[SugarColumn(ColumnName="OperIp" )]
public string OperIp { get; set; }
public string? OperIp { get; set; }
/// <summary>
/// 操作地点
///</summary>
[SugarColumn(ColumnName="OperLocation" )]
public string OperLocation { get; set; }
public string? OperLocation { get; set; }
/// <summary>
/// 操作方法
///</summary>
[SugarColumn(ColumnName="Method" )]
public string Method { get; set; }
public string? Method { get; set; }
/// <summary>
/// 请求参数
///</summary>
[SugarColumn(ColumnName="RequestParam" )]
public string RequestParam { get; set; }
public string? RequestParam { get; set; }
/// <summary>
/// 请求结果
///</summary>
[SugarColumn(ColumnName="RequestResult" )]
public string RequestResult { get; set; }
public string? RequestResult { get; set; }
/// <summary>
/// 创建者
///</summary>
@@ -97,7 +97,7 @@ namespace Yi.Framework.Model.Models
/// 描述
///</summary>
[SugarColumn(ColumnName="Remark" )]
public string Remark { get; set; }
public string? Remark { get; set; }
/// <summary>
/// 是否删除
///</summary>

View File

@@ -22,12 +22,12 @@ namespace Yi.Framework.Model.Models
/// 岗位编码
///</summary>
[SugarColumn(ColumnName="PostCode" )]
public string PostCode { get; set; }
public string? PostCode { get; set; }
/// <summary>
/// 岗位名称
///</summary>
[SugarColumn(ColumnName="PostName" )]
public string PostName { get; set; }
public string? PostName { get; set; }
/// <summary>
/// 创建者
///</summary>
@@ -67,6 +67,6 @@ namespace Yi.Framework.Model.Models
/// 描述
///</summary>
[SugarColumn(ColumnName="Remark" )]
public string Remark { get; set; }
public string? Remark { get; set; }
}
}

View File

@@ -67,6 +67,6 @@ namespace Yi.Framework.Model.Models
/// 描述
///</summary>
[SugarColumn(ColumnName="Remark" )]
public string Remark { get; set; }
public string? Remark { get; set; }
}
}

View File

@@ -9,20 +9,20 @@ namespace Yi.Framework.Model.Models
/// 角色表
///</summary>
[SugarTable("Role")]
public partial class RoleEntity:IBaseModelEntity
public partial class RoleEntity : IBaseModelEntity
{
public RoleEntity()
{
this.CreateTime = DateTime.Now;
}
[JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(ColumnName="Id" ,IsPrimaryKey = true )]
public long Id { get; set; }
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
public long Id { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="RoleName" )]
public string RoleName { get; set; }
[SugarColumn(ColumnName = "RoleName")]
public string? RoleName { get; set; }
/// <summary>
/// 创建者
///</summary>
@@ -57,7 +57,7 @@ namespace Yi.Framework.Model.Models
/// 角色编码
///</summary>
[SugarColumn(ColumnName="RoleCode" )]
public string RoleCode { get; set; }
public string? RoleCode { get; set; }
/// <summary>
/// 排序字段
///</summary>
@@ -67,7 +67,7 @@ namespace Yi.Framework.Model.Models
/// 描述
///</summary>
[SugarColumn(ColumnName="Remark" )]
public string Remark { get; set; }
public string? Remark { get; set; }
/// <summary>
/// 角色数据范围
///</summary>

View File

@@ -22,7 +22,7 @@ namespace Yi.Framework.Model.Models
///
///</summary>
[SugarColumn(ColumnName="TenantName" )]
public string TenantName { get; set; }
public string? TenantName { get; set; }
/// <summary>
/// 创建者
///</summary>
@@ -62,6 +62,6 @@ namespace Yi.Framework.Model.Models
/// 描述
///</summary>
[SugarColumn(ColumnName="Remark" )]
public string Remark { get; set; }
public string? Remark { get; set; }
}
}

View File

@@ -22,7 +22,7 @@ namespace Yi.Framework.Model.Models
///
///</summary>
[SugarColumn(ColumnName="Name" )]
public string Name { get; set; }
public string? Name { get; set; }
/// <summary>
///
///</summary>
@@ -72,42 +72,42 @@ namespace Yi.Framework.Model.Models
///
///</summary>
[SugarColumn(ColumnName="Salt" )]
public string Salt { get; set; }
public string? Salt { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="Icon" )]
public string Icon { get; set; }
public string? Icon { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="Nick" )]
public string Nick { get; set; }
public string? Nick { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="Email" )]
public string Email { get; set; }
public string? Email { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="Ip" )]
public string Ip { get; set; }
public string? Ip { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="Address" )]
public string Address { get; set; }
public string? Address { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="Phone" )]
public string Phone { get; set; }
public string? Phone { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="Introduction" )]
public string Introduction { get; set; }
public string? Introduction { get; set; }
/// <summary>
/// 排序字段
///</summary>
@@ -117,7 +117,7 @@ namespace Yi.Framework.Model.Models
/// 描述
///</summary>
[SugarColumn(ColumnName="Remark" )]
public string Remark { get; set; }
public string? Remark { get; set; }
/// <summary>
/// 部门id
///</summary>

View File

@@ -67,6 +67,6 @@ namespace Yi.Framework.Model.Models
/// 描述
///</summary>
[SugarColumn(ColumnName="Remark" )]
public string Remark { get; set; }
public string? Remark { get; set; }
}
}

View File

@@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>

View File

@@ -13,7 +13,12 @@ namespace Yi.Framework.WebCore.DbExtend
{
public static class DbSeedExtend
{
public static bool Invoer(ISqlSugarClient _Db)
/// <summary>
/// 初始化数据
/// </summary>
/// <param name="_Db"></param>
/// <returns></returns>
public static bool DataInvoer(ISqlSugarClient _Db)
{
bool res = false;
var users = SeedFactory.GetUserSeed();
@@ -87,14 +92,40 @@ namespace Yi.Framework.WebCore.DbExtend
return res;
}
/// <summary>
/// codeFirst初始化表
/// </summary>
/// <param name="_Db"></param>
/// <returns></returns>
public static void TableInvoer(ISqlSugarClient _Db)
{
//创建数据库
_Db.DbMaintenance.CreateDatabase();
var typeList = Common.Helper.AssemblyHelper.GetClass("Yi.Framework.Model");
foreach (var t in typeList)
{
//扫描如果存在SugarTable特性直接codefirst
if (t.GetCustomAttributes(false).Any(a => a.GetType().Equals(typeof(SugarTable))))
{
_Db.CodeFirst.SetStringDefaultLength(200).InitTables(t);//这样一个表就能成功创建了
}
}
}
public static void UseDbSeedInitService(this IApplicationBuilder app)
{
if (Appsettings.appBool("DbCodeFirst_Enabled"))
{
var _Db = app.ApplicationServices.GetRequiredService<ISqlSugarClient>();
TableInvoer(_Db);
}
if (Appsettings.appBool("DbSeed_Enabled"))
{
var _Db = app.ApplicationServices.GetRequiredService<ISqlSugarClient>();
Invoer(_Db);
DataInvoer(_Db);
}
}

View File

@@ -4,6 +4,7 @@ using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Common.Models;
@@ -50,9 +51,16 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
{
EntityService = (c, p) =>
{
// int? decimal?这种 isnullable=true
if (c.PropertyType.IsGenericType &&
c.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
//// int? decimal?这种 isnullable=true
//if (c.PropertyType.IsGenericType &&
//c.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
//{
// p.IsNullable = true;
//}
//高版C#写法 支持string?和string
if (new NullabilityInfoContext()
.Create(c).WriteState is NullabilityState.Nullable)
{
p.IsNullable = true;
}