using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using CellularManagement.Domain.Entities.Device; namespace CellularManagement.Infrastructure.Configurations.Device; public class ScenarioConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("Scenarios", t => t.HasComment("场景表")); builder.HasKey(s => s.Id); // 配置索引 builder.HasIndex(s => s.Code).IsUnique().HasDatabaseName("IX_Scenarios_Code"); builder.HasIndex(s => s.NetworkConfigId).HasDatabaseName("IX_Scenarios_NetworkConfigId"); // 配置属性 builder.Property(s => s.Id).HasComment("场景ID"); builder.Property(s => s.Code).IsRequired().HasMaxLength(50).HasComment("场景编码"); builder.Property(s => s.Name).IsRequired().HasMaxLength(100).HasComment("场景名称"); builder.Property(s => s.NetworkConfigId).IsRequired().HasMaxLength(50).HasComment("网络配置ID"); builder.Property(s => s.Description).HasMaxLength(1000).HasComment("说明"); builder.Property(s => s.IsDisabled).IsRequired().HasComment("是否禁用"); builder.Property(s => s.CreatedAt).IsRequired().HasColumnType("timestamp with time zone").HasComment("创建时间"); builder.Property(s => s.UpdatedAt).HasColumnType("timestamp with time zone").HasComment("更新时间"); builder.Property(s => s.CreatedBy).IsRequired().HasMaxLength(50).HasComment("创建人"); builder.Property(s => s.UpdatedBy).HasMaxLength(50).HasComment("修改人"); } }