using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace AutobusApi.Infrastructure.Data.Configurations; public class RouteAddressDeatilsConfiguration : EntityBaseConfiguration { public override void Configure(EntityTypeBuilder builder) { base.Configure(builder); builder .ToTable("route_address_details") .HasKey(e => e.Id); builder .Property(rad => rad.TimeToNextAddress) .HasColumnName("time_to_next_address") .HasColumnType("interval") .IsRequired(); builder .Property(rad => rad.CurrentAddressStopTime) .HasColumnName("current_address_stop_time") .HasColumnType("interval") .IsRequired(); builder .Property(rad => rad.CostToNextAddress) .HasColumnName("cost_to_next_address") .HasColumnType("numeric(16,4)") .IsRequired(); builder .Property(rad => rad.RouteAddressId) .HasColumnName("route_address_id") .HasColumnType("int") .IsRequired(); builder .HasOne(rad => rad.RouteAddress) .WithMany(ra => ra.RouteAddressDetails) .HasForeignKey(rad => rad.RouteAddressId) .HasConstraintName("fk_routeAddressDetails_routeAddress_routeAddressId") .OnDelete(DeleteBehavior.Cascade); builder .Property(rad => rad.VehicleEnrollmentId) .HasColumnName("vehicle_enrollment_id") .HasColumnType("int") .IsRequired(); builder .HasOne(rad => rad.VehicleEnrollment) .WithMany(ve => ve.RouteAddressDetails) .HasForeignKey(rad => rad.VehicleEnrollmentId) .HasConstraintName("fk_routeAddressDetails_vehicleEnrollments_vehicleEnrollmentId") .OnDelete(DeleteBehavior.Cascade); } }