34 lines
985 B
C#
34 lines
985 B
C#
using Cloud.Models;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Model;
|
|
|
|
namespace Cloud;
|
|
|
|
public class AppDbContext : DbContext
|
|
{
|
|
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
|
|
{
|
|
}
|
|
|
|
public DbSet<User> Users { get; set; }
|
|
public DbSet<CardNote> CardNotes { get; set; }
|
|
public DbSet<UserDeck> UserDecks { get; set; }
|
|
public DbSet<PasskeyCredential> PasskeyCredentials { get; set; }
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<User>(b => { b.HasKey(u => u.Username); });
|
|
|
|
modelBuilder.Entity<CardNote>(b => { b.HasKey(n => new { n.Username, n.CardName }); });
|
|
|
|
modelBuilder.Entity<UserDeck>(b =>
|
|
{
|
|
b.HasKey(d => d.Id);
|
|
if (Database.IsNpgsql())
|
|
{
|
|
b.Property(d => d.Cards).HasColumnType("jsonb");
|
|
b.Property(d => d.Divers).HasColumnType("jsonb");
|
|
}
|
|
});
|
|
}
|
|
} |