| 123456789101112131415161718192021222324 |
- using Domain.Entities.Forum.Comments;
- using Microsoft.EntityFrameworkCore;
- using Microsoft.EntityFrameworkCore.Metadata.Builders;
- namespace Infrastructure.Persistence.Configurations.Forum.Comments;
- public sealed class CommentFileConfiguration : IEntityTypeConfiguration<CommentFile>
- {
- public void Configure(EntityTypeBuilder<CommentFile> builder)
- {
- builder.HasIndex(x => x.BoardID);
- builder.HasIndex(x => x.PostID);
- builder.HasIndex(x => x.CommentID);
- builder.HasIndex(x => x.UUID).IsUnique();
- builder.HasOne(x => x.Board).WithMany().HasForeignKey(x => x.BoardID).OnDelete(DeleteBehavior.Restrict);
- builder.HasOne(x => x.Post).WithMany().HasForeignKey(x => x.PostID).OnDelete(DeleteBehavior.Restrict);
- builder.HasOne(x => x.Comment).WithMany(x => x.CommentFile).HasForeignKey(x => x.CommentID).OnDelete(DeleteBehavior.Cascade);
- builder.ToTable("CommentFile", x => x.HasComment("댓글 파일"));
- builder.HasKey(x => x.ID);
- builder.Property(x => x.ID).ValueGeneratedOnAdd().HasComment("PK");
- }
- }
|