using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using WebApp.Entities; namespace WebApp.Data { public class ApplicationDbContext : IdentityDbContext//, string> { public ApplicationDbContext(DbContextOptions options) : base(options) { } public DbSet WebUsers => Set(); public DbSet Tokens => Set(); public DbSet Organisations => Set(); public DbSet Events => Set(); public DbSet Skills => Set(); public DbSet VolunteerSkills => Set(); public DbSet EventSkills => Set(); public DbSet EventRegistrations => Set(); public DbSet Messages => Set(); public DbSet MessagesActivities => Set(); protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); // Compose keys builder.Entity() .HasKey(vs => new { vs.UserId, vs.SkillId }); builder.Entity() .HasKey(es => new { es.EventId, es.SkillId }); builder.Entity() .HasKey(er => new { er.VolunteerId, er.EventId }); builder.Entity() .HasKey(ma => new { ma.Sender, ma.Recipient }); } } }