Files
Backend-Api/CompanyManagment.EFCore/Mapping/LeftWorkInsuranceMapping.cs
2024-07-05 21:36:15 +03:30

30 lines
968 B
C#

using Company.Domain.LeftWorkInsuranceAgg;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CompanyManagment.EFCore.Mapping;
public class LeftWorkInsuranceMapping : IEntityTypeConfiguration<LeftWorkInsurance>
{
public void Configure(EntityTypeBuilder<LeftWorkInsurance> builder)
{
builder.ToTable("LeftWorkInsurances");
builder.HasKey(x => x.id);
builder.Property(x => x.LeftWorkDate)
.HasColumnType("datetime2(7)")
.IsRequired(false);
builder.Property(x => x.EmployeeFullName).HasMaxLength(255);
builder.Property(x => x.WorkshopName).HasMaxLength(255);
builder.HasOne(x => x.Employee)
.WithMany(x => x.LeftWorkInsurances)
.HasForeignKey(x => x.EmployeeId);
builder.HasOne(x => x.Workshop)
.WithMany(x => x.LeftWorkInsurances)
.HasForeignKey(x => x.WorkshopId);
}
}