mirror of
https://gitea.tendokyu.moe/Kayori/Medusa.net.git
synced 2026-09-26 08:18:01 +03:00
27 lines
793 B
C#
27 lines
793 B
C#
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System;
|
|
using Abstractions.Entities;
|
|
|
|
namespace Server
|
|
{
|
|
public class AppDbContext(DbContextOptions<AppDbContext> options)
|
|
: IdentityDbContext<User, IdentityRole<long>, long>(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);
|
|
}
|
|
}
|
|
}
|