using Microsoft.EntityFrameworkCore; using Model; namespace API.Data; public class AppDbContext : DbContext { public AppDbContext(DbContextOptions options) : base(options) { } public DbSet Users { get; set; } = default!; public DbSet CardNotes { get; set; } = default!; public DbSet UserDecks { get; set; } = default!; protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity(b => { b.HasKey(u => u.Username); }); modelBuilder.Entity(b => { b.HasKey(n => new { n.Username, n.CardName }); }); modelBuilder.Entity(b => { b.HasKey(d => d.Id); if (Database.IsNpgsql()) { b.Property(d => d.Cards).HasColumnType("jsonb"); b.Property(d => d.Divers).HasColumnType("jsonb"); } }); } }