using System; using ExamTemplate.Data.Models; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; namespace ExamTemplate.Data { public class TemplateContext : IdentityDbContext { public TemplateContext(DbContextOptions options) : base(options) { } protected override void OnModelCreating(ModelBuilder builder) { builder.Entity() .HasIndex(x => x.UserName) .IsUnique(); builder.Entity() .HasMany(x => x.Roles) .WithMany(x => x.Users); base.OnModelCreating(builder); } } }