28 lines
722 B
C#
28 lines
722 B
C#
using AutobusApi.Domain.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace AutobusApi.Persistence.Contexts.Configurations;
|
|
|
|
public class UserConfiguration : EntityBaseConfiguration<User>
|
|
{
|
|
public override void Configure(EntityTypeBuilder<User> builder)
|
|
{
|
|
base.Configure(builder);
|
|
|
|
builder
|
|
.ToTable("users")
|
|
.HasKey(e => e.Id);
|
|
|
|
builder
|
|
.HasMany(u => u.Reviews)
|
|
.WithOne(r => r.User)
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
builder
|
|
.HasMany(u => u.TicketGroups)
|
|
.WithOne(tg => tg.User)
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
}
|
|
}
|