autobus-api_old/AutobusApi.Persistence/Contexts/Configurations/AircraftConfiguration.cs

58 lines
1.5 KiB
C#

using AutobusApi.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace AutobusApi.Persistence.Contexts.Configurations;
public class AircraftConfiguration : EntityBaseConfiguration<Aircraft>
{
public override void Configure(EntityTypeBuilder<Aircraft> builder)
{
builder
.ToTable("aircrafts");
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.HasWiFi)
.HasColumnName("has_wifi")
.HasColumnType("boolean")
.IsRequired();
builder
.Property(b => b.HasMultimedia)
.HasColumnName("has_multimedia")
.HasColumnType("boolean")
.IsRequired();
builder
.Property(b => b.Id)
.HasColumnName("id")
.HasColumnType("int")
.IsRequired();
builder
.HasOne(b => b.Vehicle)
.WithOne()
.HasForeignKey<Aircraft>(b => b.Id)
.HasConstraintName("fk_aircrafts_vehicles_id")
.OnDelete(DeleteBehavior.Cascade);
}
}