using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace AutobusApi.Infrastructure.Data.Configurations; public class VehicleConfiguration : EntityBaseConfiguration { public override void Configure(EntityTypeBuilder builder) { base.Configure(builder); builder .UseTptMappingStrategy() .ToTable("vehicles") .HasKey(e => e.Id); builder .Property(v => v.CompanyId) .HasColumnName("company_id") .HasColumnType("int") .IsRequired(); builder .HasOne(v => v.Company) .WithMany(c => c.Vehicles) .HasForeignKey(v => v.CompanyId) .HasConstraintName("fk_vehicles_companies_companyId") .OnDelete(DeleteBehavior.Cascade); builder .HasMany(v => v.Enrollments) .WithOne(ve => ve.Vehicle) .OnDelete(DeleteBehavior.Cascade); } }