using GamificationService.Models.Database; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; namespace GamificationService.Database; public class ApplicationContext : IdentityDbContext { public ApplicationContext(DbContextOptions options) : base(options) { } public DbSet Rights { get; set; } public DbSet RefreshTokens { get; set; } public DbSet Users { get; set; } public DbSet Roles { get; set; } public DbSet UserRoles { get; set; } public DbSet RoleRights { get; set; } public DbSet UserProfiles { get; set; } public DbSet Instructions { get; set; } public DbSet InstructionCategories { get; set; } public DbSet InstructionParagraphs { get; set; } public DbSet InstructionTests { get; set; } public DbSet InstructionTestQuestions { get; set; } public DbSet InstructionTestResults { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Entity() .HasKey(ur => new { ur.UserId, ur.RoleId }); modelBuilder.Entity() .HasKey(rr => new { rr.RoleId, rr.RightId }); modelBuilder.Entity() .HasMany(itq => itq.Questions); modelBuilder.Entity() .HasOne(itr => itr.InstructionTest); modelBuilder.Entity() .HasOne(i => i.Category); modelBuilder.Entity() .HasMany(i => i.Paragraphs); } }