| 123456789101112131415161718192021222324 |
- using Domain.Entities.Forum.Posts;
- using Microsoft.EntityFrameworkCore;
- using Microsoft.EntityFrameworkCore.Metadata.Builders;
- namespace Infrastructure.Persistence.Configurations.Forum.Posts;
- public sealed class PostBookmarkConfiguration : IEntityTypeConfiguration<PostBookmark>
- {
- public void Configure(EntityTypeBuilder<PostBookmark> builder)
- {
- builder.HasIndex(x => x.BoardID);
- builder.HasIndex(x => x.PostID);
- builder.HasIndex(x => x.MemberID);
- builder.HasIndex(x => new { x.PostID, x.MemberID }).IsUnique();
- builder.HasOne(x => x.Board).WithMany().HasForeignKey(x => x.BoardID).OnDelete(DeleteBehavior.Restrict);
- builder.HasOne(x => x.Post).WithMany(x => x.PostBookmark).HasForeignKey(x => x.PostID).OnDelete(DeleteBehavior.Cascade);
- builder.HasOne(x => x.Member).WithMany().HasForeignKey(x => x.MemberID).OnDelete(DeleteBehavior.Cascade);
- builder.ToTable("PostBookmark", x => x.HasComment("게시글 즐겨찾기"));
- builder.HasKey(x => x.ID);
- builder.Property(x => x.ID).ValueGeneratedOnAdd().HasComment("PK");
- }
- }
|