Files
Backend-Api/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/BugSectionMapping.cs
2026-01-27 13:40:05 +03:30

51 lines
1.4 KiB
C#

using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace GozareshgirProgramManager.Infrastructure.Persistence.Mappings;
public class BugSectionMapping : IEntityTypeConfiguration<BugSection>
{
public void Configure(EntityTypeBuilder<BugSection> 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<string>()
.HasMaxLength(50)
.IsRequired();
builder.Property(x => x.Priority)
.HasConversion<string>()
.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);
}
}