using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace AutobusApi.Infrastructure.Data.Configurations; public class CompanyConfiguration : EntityBaseConfiguration { public override void Configure(EntityTypeBuilder builder) { base.Configure(builder); builder .ToTable("companies") .HasKey(e => e.Id); builder .Property(c => c.Name) .HasColumnName("name") .HasColumnType("varchar(64)") .IsRequired(); builder .Property(c => c.LegalAddress) .HasColumnName("legal_address") .HasColumnType("varchar(256)") .IsRequired(); builder .Property(c => c.ContactEmail) .HasColumnName("contact_email") .HasColumnType("varchar(256)") .IsRequired(); builder .Property(c => c.ContactPhoneNumber) .HasColumnName("contact_phone_number") .HasColumnType("varchar(16)") .IsRequired(); builder .HasMany(c => c.Employees) .WithOne(e => e.EmployerCompany) .OnDelete(DeleteBehavior.Cascade); builder .HasMany(c => c.Vehicles) .WithOne(v => v.Company) .OnDelete(DeleteBehavior.Cascade); } }