在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
表生成的效果
索引創建效果: