ABP-VNext 用户权限管理系统实战06---实体的创建标准及迁移

在apb-vnext的实体的创建中可以确实字段的长度、说明、对应的表、表中给字段加的索引

以项目中的订单表为例,如下:

 [Comment("订单主表")]
 [Table("t_voucher_order")]
 [Index(nameof(VoucherCode))]
public class Order : AuditedAggregateRoot<Guid>, ISoftDelete, IMultiTenant { public Order() { } public Order(Guid id) { this.Id = id; } /// <summary> /// 单据编号 /// </summary> [MaxLength(32)] [Comment("单据编号")] public string VoucherCode { get; set; } /// <summary> /// 发货仓库 /// </summary> [MaxLength(36)] [Comment("发货仓库")] public Guid WarehouseId { get; set; } /// <summary> /// 发货仓库 /// </summary> [MaxLength(50)] [Comment("仓库名称")] public string WarehouseName { get; set; } /// <summary> /// 供应商编码 /// </summary> [MaxLength(36)] [Comment("供应商编码")] public Guid? SupplierId { get; set; } /// <summary> /// 供应商名称 /// </summary> [MaxLength(20)] [Comment("供应商名称")] public string SupplierName { get; set; } /// <summary> /// 申请时间 /// </summary> [Comment("申请时间")] public DateTime CreatedOn { get; set; } /// <summary> /// 申请人 /// </summary> [MaxLength(20)] [Comment("申请人")] public string CreatedBy { get; set; } /// <summary> /// 审核时间 /// </summary> [Comment("审核时间")] public DateTime? AuditOn { get; set; } /// <summary> /// 审核人 /// </summary> [MaxLength(20)] [Comment("审核人")] public string AuditBy { get; set; } /// <summary> /// 订单状态:0 暂存 1已作废 2已提交 3已驳回 5已审核 /// </summary> [Comment("订单状态")] public OrderStatusEnum Status { get; set; } /// <summary> /// 删除标识 /// </summary> [Comment("删除标识")] public bool IsDeleted { get; set; } = false; public Guid? TenantId { get; set; } }

迁移表到数据库后看效果

 Add-Migration order202405110001

 表生成的效果

 索引创建效果:

 

posted @ 2024-05-11 16:58  爱生活,爱代码  阅读(296)  评论(1编辑  收藏  举报