29 lines
764 B
C#
29 lines
764 B
C#
using AutobusApi.Domain.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace AutobusApi.Persistence.Contexts.Configurations;
|
|
|
|
public class CountryConfiguration : EntityBaseConfiguration<Country>
|
|
{
|
|
public override void Configure(EntityTypeBuilder<Country> builder)
|
|
{
|
|
base.Configure(builder);
|
|
|
|
builder
|
|
.ToTable("countries")
|
|
.HasKey(e => e.Id);
|
|
|
|
builder
|
|
.Property(c => c.Name)
|
|
.HasColumnName("name")
|
|
.HasColumnType("varchar(64)")
|
|
.IsRequired();
|
|
|
|
builder
|
|
.HasMany(c => c.Regions)
|
|
.WithOne(r => r.Country)
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
}
|
|
}
|