Files
SpotiParty/SpotiParty.Web/DatabaseContext.cs

20 lines
549 B
C#

using Microsoft.EntityFrameworkCore;
using SpotiParty.Web.Models;
namespace SpotiParty.Web;
public class DatabaseContext(DbContextOptions<DatabaseContext> options) : DbContext(options) {
public DbSet<User> Users { get; set; }
public DbSet<Event> Events { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder) {
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Event>()
.HasOne(e => e.Host)
.WithMany()
.OnDelete(DeleteBehavior.Cascade);
}
}