mirror of
https://github.com/CannedNet/CannedNet.git
synced 2026-10-26 15:38:57 -07:00
current src
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace CannedNet.Data;
|
||||
|
||||
public class AppDbContext : DbContext
|
||||
{
|
||||
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public DbSet<Account> Accounts { get; set; }
|
||||
public DbSet<CachedLogin> CachedLogins { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
// accounts
|
||||
modelBuilder.Entity<Account>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.AccountId);
|
||||
entity.Property(e => e.AccountId).ValueGeneratedNever();
|
||||
entity.Property(e => e.Username).IsRequired();
|
||||
entity.Property(e => e.DisplayName).IsRequired();
|
||||
entity.ToTable("accounts");
|
||||
});
|
||||
|
||||
// cachedlogins
|
||||
modelBuilder.Entity<CachedLogin>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
entity.HasIndex(e => new { e.Platform, e.PlatformID }).IsUnique();
|
||||
entity.ToTable("cached_logins");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user