2
schangxiang@126.com
2025-05-11 4d916744ba1ba9066d1ecf809f43ddddb817b26b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace CMS.Plugin.MyExtension.Domain
{
    /// <summary>
    /// 用于扩展 EntityTypeBuilder 的静态类,提供针对继承自 MyFullAuditedAggregateRoot<Guid> 的实体类型的配置扩展方法
    /// </summary>
    public static class EntityTypeBuilderExtensions
    {
        /// <summary>
        /// 针对继承自 MyFullAuditedAggregateRoot<Guid> 的实体类型,配置其公共属性
        /// </summary>
        /// <typeparam name="TEntity">继承自 MyFullAuditedAggregateRoot<Guid> 的实体类型</typeparam>
        /// <param name="b">EntityTypeBuilder<TEntity> 实例,用于配置实体的属性</param>
        public static void ConfigureMyCmsEntity<TEntity>(this EntityTypeBuilder<TEntity> b) where TEntity : MyFullAuditedAggregateRoot<Guid>
        {
            b.Property(x => x.CreatorId)
             .HasMaxLength(36)
             .IsRequired(false)
             .HasComment("创建人ID");
 
            b.Property(x => x.CreatorName)
                .HasMaxLength(64)
                .IsRequired(false)
                .HasComment("创建人");
 
            b.Property(x => x.CreationTime)
                .IsRequired()
                .HasComment("创建时间");
 
            b.Property(x => x.LastModifierName)
                .HasMaxLength(64)
                .IsRequired(false)
                .HasComment("修改人");
 
            b.Property(x => x.LastModifierId)
                .HasMaxLength(36)
                .IsRequired(false)
                .HasComment("修改人ID");
 
            b.Property(x => x.LastModificationTime)
                .IsRequired(false)
                .HasComment("修改时间");
 
            b.Property(x => x.IsDeleted)
                .IsRequired()
                .HasComment("是否删除");
 
            b.Property(x => x.DeleterId)
                .HasMaxLength(36)
                .IsRequired(false)
                .HasComment("删除人ID");
 
            b.Property(x => x.DeletionTime)
                .IsRequired(false)
                .HasComment("删除时间");
 
            b.Property(x => x.ExtraProperties)
                .IsRequired(false)
                .HasComment("扩展属性");
 
            b.Property(x => x.ConcurrencyStamp)
                .IsRequired(false)
                .HasMaxLength(40)
                .HasComment("并发戳");
 
            b.Property(x => x.Sort)
                .HasDefaultValue(0)
                .HasComment("排序");
 
            b.Property(x => x.Remark)
                .HasMaxLength(256)
                .IsRequired(false)
                .HasComment("备注");
 
            b.Property(x => x.OperationRemark)
               .HasMaxLength(256)
               .IsRequired(false)
               .HasComment("操作备注");
 
            b.Property(x => x.DeleteRemark)
              .HasMaxLength(256)
              .IsRequired(false)
              .HasComment("删除备注");
 
            b.Property(x => x.IsDisabled)
                .IsRequired(false)
                .HasDefaultValue(false)
                .HasComment("是否禁用");
 
            b.Property(x => x.ExtraField1)
              .HasMaxLength(256)
              .IsRequired(false)
              .HasComment("扩展字段1");
 
            b.Property(x => x.ExtraField2)
               .HasMaxLength(256)
               .IsRequired(false)
               .HasComment("扩展字段2");
 
            b.Property(x => x.ExtraField3)
             .HasMaxLength(256)
             .IsRequired(false)
             .HasComment("扩展字段3");
 
        }
    }
}