PLCConfiguration.cs
2.32 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
74
75
76
77
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using HaHRCS.Rcs.Model.Entities;
namespace Rcs.Infrastructure.DB.Configuration.Domain
{
/// <summary>
/// PLC EF Core 配置
/// </summary>
public class PLCConfiguration : IEntityTypeConfiguration<PLC>
{
public void Configure(EntityTypeBuilder<PLC> builder)
{
// 表名
builder.ToTable("wcs_plc");
// 主键
builder.HasKey(e => e.Id);
// ==================== 主键 ====================
builder.Property(e => e.Id)
.HasColumnName("Id")
.ValueGeneratedOnAdd();
// ==================== 创建/更新信息 ====================
builder.Property(e => e.CreateTime)
.HasColumnName("CreateTime");
builder.Property(e => e.CreateBy)
.HasColumnName("CreateBy")
.HasMaxLength(20);
builder.Property(e => e.UpdateTime)
.HasColumnName("UpdateTime");
builder.Property(e => e.UpdateBy)
.HasColumnName("UpdateBy")
.HasMaxLength(20);
// ==================== 业务字段 ====================
builder.Property(e => e.Code)
.HasColumnName("Code")
.HasMaxLength(50);
builder.Property(e => e.Name)
.HasColumnName("Name")
.HasMaxLength(100);
builder.Property(e => e.IP)
.HasColumnName("IP")
.HasMaxLength(50);
builder.Property(e => e.Brand)
.HasColumnName("Brand")
.HasMaxLength(50);
builder.Property(e => e.Type)
.HasColumnName("Type")
.HasMaxLength(50);
builder.Property(e => e.LineCode)
.HasColumnName("LineCode")
.HasMaxLength(50);
builder.Property(e => e.Disable)
.HasColumnName("Disable");
// ==================== 索引 ====================
builder.HasIndex(e => e.Code)
.HasDatabaseName("idx_plc_code")
.IsUnique();
builder.HasIndex(e => e.IP)
.HasDatabaseName("idx_plc_ip");
}
}
}