33 lines
805 B
C#
33 lines
805 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using WinWARP.Core.Models.Entities;
|
|
|
|
namespace WinWARP.Core.Data;
|
|
|
|
public class AppDbContext : DbContext
|
|
{
|
|
public DbSet<Subscription> Subscriptions => Set<Subscription>();
|
|
|
|
|
|
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
|
|
{
|
|
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
base.OnModelCreating(modelBuilder);
|
|
|
|
modelBuilder.Entity<Subscription>()
|
|
.HasKey(s => s.Id);
|
|
|
|
modelBuilder.Entity<Subscription>()
|
|
.HasMany(s => s.Servers)
|
|
.WithOne(s => s.Subscription)
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
modelBuilder.Entity<StandaloneServer>();
|
|
}
|
|
} |