Files
hermes/WebApp/Data/ApplicationDbContext.cs
AleksDw b4b81355c1 CreateDatabase
Nic nie działa bo wszystko jest inne XDD
2025-04-27 00:40:34 +02:00

38 lines
1.3 KiB
C#

using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using WebApp.Entities;
namespace WebApp.Data
{
public class ApplicationDbContext : IdentityDbContext<User, IdentityRole<string>, string>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
public DbSet<Organisation> Organisations => Set<Organisation>();
public DbSet<Event> Events => Set<Event>();
public DbSet<Skill> Skills => Set<Skill>();
public DbSet<VolunteerSkill> VolunteerSkills => Set<VolunteerSkill>();
public DbSet<EventSkill> EventSkills => Set<EventSkill>();
public DbSet<EventRegistration> EventRegistrations => Set<EventRegistration>();
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
// Compose keys
builder.Entity<VolunteerSkill>()
.HasKey(vs => new { vs.UserId, vs.SkillId });
builder.Entity<EventSkill>()
.HasKey(es => new { es.EventId, es.SkillId });
builder.Entity<EventRegistration>()
.HasKey(er => new { er.UserId, er.EventId });
}
}
}