修改迁移配置以及测试
continuous-integration/drone/push Build is passing

This commit is contained in:
hang
2024-09-17 23:16:11 +08:00
parent 65e47d9918
commit 19b647fb4a
15 changed files with 296 additions and 222 deletions
@@ -197,7 +197,7 @@ public partial class <#= Options.ContextName #> : DbContext
WriteLine("");
}
#>
entity.Property(e => e.<#= property.Name #>)<#= code.Fragment(propertyFluentApiCalls, indent: 4) #>;
entity.Property(e => e.<#= property.GetColumnName() #>)<#= code.Fragment(propertyFluentApiCalls, indent: 4) #>;
<#
anyEntityTypeConfiguration = true;
firstProperty = false;
@@ -49,7 +49,7 @@ namespace <#= NamespaceHint #>;
if (!string.IsNullOrEmpty(EntityType.GetComment()))
{
#>
[Comment("<#= code.XmlComment(EntityType.GetComment()) #>")]
[Comment("<#= code.XmlComment(EntityType.GetComment().Replace("\\", "|").Trim()) #>")]
<#
}
@@ -80,9 +80,10 @@ public partial class <#= EntityType.Name #>: BaseFullAuditEntity
if (!string.IsNullOrEmpty(property.GetComment()))
{
#>
[Comment(" <#= code.XmlComment(property.GetComment()) #>")]
[Comment(" <#= code.XmlComment(property.GetComment().Replace("\\", "|").Trim()) #>")]
<#
}
if (Options.UseDataAnnotations)
{
@@ -93,14 +94,9 @@ public partial class <#= EntityType.Name #>: BaseFullAuditEntity
if (maxLength.HasValue && maxLength != 200) // 仅当长度不为200时生成[StringLength]
{
#>
[StringLength(<#= maxLength.Value #>)]
<#
<#
}
else
{
@@ -134,7 +130,7 @@ public partial class <#= EntityType.Name #>: BaseFullAuditEntity
var dataAnnotations = property.GetDataAnnotations(annotationCodeGenerator)
.Where(a => !(a.Type == typeof(RequiredAttribute) && Options.UseNullableReferenceTypes && !property.ClrType.IsValueType)
&& a.Type != typeof(StringLengthAttribute) // 排除 StringLengthAttribute
);
);
foreach (var dataAnnotation in dataAnnotations)
{
@@ -143,6 +139,11 @@ public partial class <#= EntityType.Name #>: BaseFullAuditEntity
{
continue;
}
if(dataAnnotation.Arguments?[0]== property.GetColumnName() && property.GetColumnName() !=property.Name )
{
continue;
}
#>
<#= code.Fragment(dataAnnotation) #>
@@ -155,7 +156,7 @@ public partial class <#= EntityType.Name #>: BaseFullAuditEntity
var needsNullable = Options.UseNullableReferenceTypes && property.IsNullable && !property.ClrType.IsValueType;
var needsInitializer = Options.UseNullableReferenceTypes && !property.IsNullable && !property.ClrType.IsValueType;
#>
public <#= code.Reference(property.ClrType) #><#= needsNullable ? "?" : "" #> <#= property.Name #> { get; set; }<#= needsInitializer ? " = null!;" : "" #>
public <#= code.Reference(property.ClrType) #><#= needsNullable ? "?" : "" #> <#= property.GetColumnName() #> { get; set; }<#= needsInitializer ? " = null!;" : "" #>
<#
firstProperty = false;
}