using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace AutobusApi.Infrastructure.Data.Configurations; public class TicketConfiguration : EntityBaseConfiguration { public override void Configure(EntityTypeBuilder builder) { base.Configure(builder); builder .ToTable("tickets") .HasKey(e => e.Id); builder .Property(t => t.VehicleEnrollmentId) .HasColumnName("vehicle_enrollment_id") .HasColumnType("int") .IsRequired(); builder .HasOne(t => t.VehicleEnrollment) .WithMany(ve => ve.Tickets) .HasForeignKey(t => t.VehicleEnrollmentId) .HasConstraintName("fk_tickets_vehicleEnrollments_vehicleEnrollmentId") .OnDelete(DeleteBehavior.Cascade); builder .Property(t => t.TicketGroupId) .HasColumnName("ticket_group_id") .HasColumnType("int") .IsRequired(); builder .HasOne(t => t.TicketGroup) .WithMany(ve => ve.Tickets) .HasForeignKey(t => t.TicketGroupId) .HasConstraintName("fk_tickets_ticketGroups_ticketGroupId") .OnDelete(DeleteBehavior.Cascade); } }