using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace AutobusApi.Infrastructure.Data.Configurations; public class TrainCarriageConfiguration : EntityBaseConfiguration { public override void Configure(EntityTypeBuilder builder) { base.Configure(builder); builder .ToTable("train_carriages") .HasKey(e => e.Id); builder .Property(b => b.TrainId) .HasColumnName("train_id") .HasColumnType("int") .IsRequired(); builder .HasOne(tc => tc.Train) .WithMany(t => t.TrainCarriage) .HasForeignKey(tc => tc.TrainId) .HasConstraintName("fk_trainCarriages_trains_trainId") .OnDelete(DeleteBehavior.Cascade); builder .Property(b => b.CarriageId) .HasColumnName("carriage_id") .HasColumnType("int") .IsRequired(); builder .HasOne(tc => tc.Carriage) .WithMany(c => c.TrainCarriage) .HasForeignKey(tc => tc.TrainId) .HasConstraintName("fk_trainCarriages_trains_carriageId") .OnDelete(DeleteBehavior.Cascade); } }