mirror of
https://gitea.tendokyu.moe/Kayori/Medusa.net.git
synced 2026-09-22 22:38:00 +03:00
27 lines
785 B
C#
27 lines
785 B
C#
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Server.Entities;
|
|
using System;
|
|
|
|
namespace Server
|
|
{
|
|
public class AppDbContext(DbContextOptions<AppDbContext> options)
|
|
: IdentityDbContext<User, IdentityRole<int>, int>(options)
|
|
{
|
|
public override DbSet<User> Users { get; set; }
|
|
public DbSet<Card> Cards { get; set; }
|
|
|
|
protected override void OnModelCreating(ModelBuilder builder)
|
|
{
|
|
builder.Entity<User>()
|
|
.HasMany(u => u.Cards)
|
|
.WithOne(c => c.User)
|
|
.HasForeignKey(c => c.UserId)
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
base.OnModelCreating(builder);
|
|
}
|
|
}
|
|
}
|