PopupPositionConfiguration.cs 1.2 KB

12345678910111213141516171819202122232425
  1. using Domain.Entities.Page.Popup;
  2. using Microsoft.EntityFrameworkCore;
  3. using Microsoft.EntityFrameworkCore.Metadata.Builders;
  4. namespace Infrastructure.Persistence.Configurations.Page;
  5. public sealed class PopupPositionConfiguration : IEntityTypeConfiguration<PopupPosition>
  6. {
  7. public void Configure(EntityTypeBuilder<PopupPosition> builder)
  8. {
  9. builder.HasMany(x => x.Popups).WithOne(x => x.PopupPosition).HasForeignKey(x => x.PositionID).OnDelete(DeleteBehavior.Cascade);
  10. builder.HasIndex(x => x.Code).IsUnique();
  11. builder.HasIndex(x => x.IsActive);
  12. builder.HasIndex(x => new { x.Code, x.IsActive });
  13. builder.ToTable(nameof(PopupPosition), t => t.HasComment("팝업 위치"));
  14. builder.HasKey(x => x.ID);
  15. builder.Property(x => x.ID).ValueGeneratedOnAdd().HasComment("PK");
  16. builder.Property(x => x.Code).HasMaxLength(30).IsRequired().HasComment("위치 구분");
  17. builder.Property(x => x.Subject).HasMaxLength(255).IsRequired().HasComment("위치 명");
  18. builder.Property(x => x.IsActive).IsRequired().HasComment("사용 여부");
  19. builder.Property(x => x.UpdatedAt).HasComment("수정 일시");
  20. builder.Property(x => x.CreatedAt).IsRequired().HasComment("등록 일시");
  21. }
  22. }