44 lines
1.4 KiB
C#
44 lines
1.4 KiB
C#
using AutobusApi.Domain.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace AutobusApi.Persistence.Contexts.Configurations;
|
|
|
|
public class VehicleEnrollmentEmployeeConfiguration : EntityBaseConfiguration<VehicleEnrollmentEmployee>
|
|
{
|
|
public override void Configure(EntityTypeBuilder<VehicleEnrollmentEmployee> builder)
|
|
{
|
|
base.Configure(builder);
|
|
|
|
builder
|
|
.ToTable("vehicle_enrollment_employees")
|
|
.HasKey(e => e.Id);
|
|
|
|
builder
|
|
.Property(vee => vee.EmployeeId)
|
|
.HasColumnName("employee_id")
|
|
.HasColumnType("int")
|
|
.IsRequired();
|
|
|
|
builder
|
|
.HasOne(vee => vee.Employee)
|
|
.WithMany(e => e.Shifts)
|
|
.HasForeignKey(vee => vee.EmployeeId)
|
|
.HasConstraintName("fk_vehicleEnrollmentEmployees_employees_employeeId")
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
builder
|
|
.Property(vee => vee.VehicleEnrollmentId)
|
|
.HasColumnName("vehicle_enrollment_id")
|
|
.HasColumnType("int")
|
|
.IsRequired();
|
|
|
|
builder
|
|
.HasOne(vee => vee.VehicleEnrollment)
|
|
.WithMany(ve => ve.Crew)
|
|
.HasForeignKey(vee => vee.VehicleEnrollmentId)
|
|
.HasConstraintName("fk_vehicleEnrollmentEmployees_vehicleEnrollments_vehicleEnrollmentId")
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
}
|
|
}
|