using Domain.Entities.Forum.Boards; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Infrastructure.Persistence.Configurations.Forum.Boards; public sealed class BoardGroupConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.HasIndex(x => x.Code).IsUnique(); builder.HasIndex(x => x.Order); builder.HasIndex(x => new { x.Order, x.CreatedAt }); builder.HasIndex(x => new { x.Code, x.Order, x.CreatedAt }); builder.HasMany(x => x.Board).WithOne(x => x.BoardGroup).HasForeignKey(x => x.BoardGroupID).OnDelete(DeleteBehavior.Restrict); builder.ToTable(nameof(BoardGroup), x => x.HasComment("게시판 분류")); builder.HasKey(x => x.ID); builder.Property(x => x.ID).ValueGeneratedOnAdd().HasComment("PK"); builder.Property(x => x.Code).HasMaxLength(30).IsRequired().HasComment("게시판 분류 주소"); builder.Property(x => x.Name).HasMaxLength(70).IsRequired().HasComment("게시판 분류 명"); builder.Property(x => x.Order).IsRequired().HasComment("순서"); builder.Property(x => x.Boards).IsRequired().HasComment("게시판 수"); builder.Property(x => x.Posts).IsRequired().HasComment("게시글 수"); builder.Property(x => x.Comments).IsRequired().HasComment("댓글 수"); builder.Property(x => x.UpdatedAt).HasComment("수정 일시"); builder.Property(x => x.CreatedAt).IsRequired().HasComment("등록 일시"); } }