28 lines
743 B
C#
28 lines
743 B
C#
using AutobusApi.Domain.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace AutobusApi.Persistence.Contexts.Configurations;
|
|
|
|
public class RouteConfiguration : EntityBaseConfiguration<Route>
|
|
{
|
|
public override void Configure(EntityTypeBuilder<Route> builder)
|
|
{
|
|
base.Configure(builder);
|
|
|
|
builder
|
|
.ToTable("routes")
|
|
.HasKey(e => e.Id);
|
|
|
|
builder
|
|
.HasMany(r => r.VehicleEnrollments)
|
|
.WithOne(ve => ve.Route)
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
builder
|
|
.HasMany(r => r.RouteAddresses)
|
|
.WithOne(ra => ra.Route)
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
}
|
|
}
|