Files
Backend-Api/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/PhaseSectionMapping.cs

28 lines
908 B
C#

using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace GozareshgirProgramManager.Infrastructure.Persistence.Mappings;
public class PhaseSectionMapping:IEntityTypeConfiguration<PhaseSection>
{
public void Configure(EntityTypeBuilder<PhaseSection> builder)
{
builder.HasKey(ps => ps.Id);
builder.Property(ps => ps.Id)
.ValueGeneratedOnAdd();
builder.HasOne(ps => ps.Phase)
.WithMany(p => p.PhaseSections)
.HasForeignKey(ps => ps.PhaseId)
.OnDelete(DeleteBehavior.Cascade);
builder.HasOne(ps => ps.Skill)
.WithMany()
.HasForeignKey(ps => ps.SkillId)
.IsRequired(false)
.OnDelete(DeleteBehavior.Restrict);
}
}