using AutobusApi.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace AutobusApi.Infrastructure.Data.Configurations; public class UserConfiguration : EntityBaseConfiguration { public override void Configure(EntityTypeBuilder builder) { base.Configure(builder); builder .ToTable("users") .HasKey(u => u.Id); builder .Property(u => u.IdentityId) .HasColumnName("identity_id") .HasColumnType("int") .IsRequired(); builder .HasIndex(u => u.IdentityId) .IsUnique(); builder .HasMany(u => u.Reviews) .WithOne(r => r.User) .OnDelete(DeleteBehavior.Cascade); builder .HasMany(u => u.TicketGroups) .WithOne(tg => tg.User) .OnDelete(DeleteBehavior.Cascade); } }