StepActionConfiguration.cs
2.28 KB
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
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Rcs.Domain.Entities;
namespace Rcs.Infrastructure.DB.Configuration.Domain
{
/// <summary>
/// StepAction实体的EF Core配置
/// </summary>
public class StepActionConfiguration : IEntityTypeConfiguration<StepAction>
{
public void Configure(EntityTypeBuilder<StepAction> builder)
{
// 配置表名
builder.ToTable("step_actions");
// 配置主键
builder.HasKey(e => e.ActionId);
// 配置属性
builder.Property(e => e.ActionId)
.HasColumnName("action_id")
.ValueGeneratedNever();
builder.Property(e => e.PropertyId)
.HasColumnName("property_id")
.IsRequired();
builder.Property(e => e.Type)
.HasColumnName("type")
.HasMaxLength(50)
.IsRequired();
builder.Property(e => e.StepName)
.HasColumnName("step_name")
.HasMaxLength(100);
builder.Property(e => e.Description)
.HasColumnName("description")
.HasMaxLength(500);
builder.Property(e => e.Order)
.HasColumnName("order")
.IsRequired();
builder.Property(e => e.BlockingType)
.HasColumnName("blocking_type")
.IsRequired();
builder.Property(e => e.CreatedAt)
.HasColumnName("created_at")
.HasColumnType("timestamp without time zone");
builder.Property(e => e.UpdatedAt)
.HasColumnName("updated_at")
.HasColumnType("timestamp without time zone");
// 配置索引
builder.HasIndex(e => e.PropertyId)
.HasDatabaseName("idx_action_property");
builder.HasIndex(e => new { e.PropertyId, e.Order })
.HasDatabaseName("idx_action_property_order");
// 配置导航属性 - 多对一关系
builder.HasOne(e => e.Property)
.WithMany(p => p.Actions)
.HasForeignKey(e => e.PropertyId)
.OnDelete(DeleteBehavior.Cascade);
}
}
}