|
@@ -3,6 +3,7 @@ using System.ComponentModel;
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
using System.Linq.Dynamic.Core;
|
|
|
using System.Linq.Expressions;
|
|
|
+using System.Reflection;
|
|
|
using Microsoft.EntityFrameworkCore.Metadata;
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
@@ -60,11 +61,11 @@ namespace Sharing.Repository.Extensions
|
|
|
//{
|
|
|
// column.IsIgnore = true;
|
|
|
//}
|
|
|
- if (property.PropertyType.IsGenericType &&
|
|
|
- property.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
|
|
|
- {
|
|
|
- column.IsNullable = true;
|
|
|
- }
|
|
|
+ //if (property.PropertyType.IsGenericType &&
|
|
|
+ // property.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
|
|
|
+ //{
|
|
|
+ // column.IsNullable = true;
|
|
|
+ //}
|
|
|
|
|
|
if (column.PropertyName.ToLower() == "id" ||
|
|
|
attributes.Any(it => it is KeyAttribute)) //是id的设为主键
|
|
@@ -77,6 +78,12 @@ namespace Sharing.Repository.Extensions
|
|
|
// column.DbColumnName = UtilMethods.ToUnderLine(column.DbColumnName);//ToUnderLine驼峰转下划线
|
|
|
|
|
|
//column.ColumnDescription = (attributes.FirstOrDefault(d => d is DescriptionAttribute) as DescriptionAttribute)?.Description ?? string.Empty;
|
|
|
+
|
|
|
+ //统一设置 nullable等于isnullable=true
|
|
|
+ if (!column.IsPrimarykey && new NullabilityInfoContext().Create(property).WriteState is NullabilityState.Nullable)
|
|
|
+ {
|
|
|
+ column.IsNullable = true;
|
|
|
+ }
|
|
|
},
|
|
|
EntityNameService = (type, entity) =>
|
|
|
{
|