using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using NexusReader.Domain.Entities; namespace NexusReader.Infrastructure.Persistence; public class AppDbContext : IdentityDbContext { public AppDbContext(DbContextOptions options) : base(options) { } public DbSet SemanticKnowledgeCache => Set(); public DbSet Ebooks => Set(); protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Entity(entity => { entity.HasKey(e => e.ContentHash); entity.HasIndex(e => e.ContentHash).IsUnique(); }); modelBuilder.Entity(entity => { entity.HasOne(e => e.User) .WithMany(u => u.Ebooks) .HasForeignKey(e => e.UserId) .OnDelete(DeleteBehavior.Cascade); }); } }