using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace AutobusApi.Infrastructure.Data.Configurations; public class BusConfiguration : EntityBaseConfiguration { public override void Configure(EntityTypeBuilder builder) { builder .ToTable("buses"); builder .Property(b => b.Number) .HasColumnName("number") .HasColumnType("varchar(8)") .IsRequired(); builder .Property(b => b.Model) .HasColumnName("model") .HasColumnType("varchar(64)") .IsRequired(); builder .Property(b => b.Capacity) .HasColumnName("capacity") .HasColumnType("int") .IsRequired(); builder .Property(b => b.HasClimateControl) .HasColumnName("has_climate_control") .HasColumnType("boolean") .IsRequired(); builder .Property(b => b.HasWC) .HasColumnName("has_wc") .HasColumnType("boolean") .IsRequired(); builder .Property(b => b.HasWiFi) .HasColumnName("has_wifi") .HasColumnType("boolean") .IsRequired(); builder .Property(b => b.HasMultimedia) .HasColumnName("has_multimedia") .HasColumnType("boolean") .IsRequired(); builder .Property(b => b.HasOutlets) .HasColumnName("has_outlets") .HasColumnType("boolean") .IsRequired(); builder .Property(b => b.Id) .HasColumnName("id") .HasColumnType("int") .IsRequired(); builder .HasOne(b => b.Vehicle) .WithOne() .HasForeignKey(b => b.Id) .HasConstraintName("fk_buses_vehicles_id") .OnDelete(DeleteBehavior.Cascade); } }