using GozareshgirProgramManager.Domain.ProjectAgg.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace GozareshgirProgramManager.Infrastructure.Persistence.Mappings; public class BugSectionMapping : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("BugSections"); builder.HasKey(x => x.Id); builder.Property(x => x.Id) .ValueGeneratedNever(); builder.Property(x => x.TaskId) .IsRequired(); builder.Property(x => x.Status) .HasConversion() .HasMaxLength(50) .IsRequired(); builder.Property(x => x.Priority) .HasConversion() .HasMaxLength(50) .IsRequired(); builder.Property(x => x.InitialDescription) .HasMaxLength(500) .IsRequired(false); builder.OwnsMany(x => x.BugDocuments, navigationBuilder => { navigationBuilder.ToTable("BugDocuments"); navigationBuilder.HasKey(x => x.Id); navigationBuilder.WithOwner(x => x.BugSection); }); // Navigation to ProjectTask (Task level) builder.HasOne(x => x.ProjectTask) .WithMany(t => t.BugSectionList) .HasForeignKey(x => x.TaskId) .OnDelete(DeleteBehavior.Cascade); } }