using LEA.Models; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; namespace LEA.Data; public class AppDbContext : IdentityDbContext { public AppDbContext(DbContextOptions options) : base(options) { } public DbSet Applications { get; set; } = null!; public DbSet Contacts { get; set; } = null!; protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); builder.Entity() .HasOne(a => a.User) .WithMany() .HasForeignKey(a => a.UserId) .OnDelete(DeleteBehavior.Cascade); builder.Entity() .HasOne(a => a.Contact) .WithOne(c => c.Application) .HasForeignKey(c => c.ApplicationId) .OnDelete(DeleteBehavior.Cascade); builder.Entity() .Property(a => a.Status) .HasConversion() .HasMaxLength(50); } }