blob: ef675a3d10fbe8aa26978568694b7ef95c4cbcfd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
using System;
using ExamTemplate.Data.Models;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
namespace ExamTemplate.Data
{
public class TemplateContext : IdentityDbContext<User, Role, Guid>
{
public TemplateContext(DbContextOptions<TemplateContext> options)
: base(options) { }
protected override void OnModelCreating(ModelBuilder builder)
{
builder.Entity<User>()
.HasIndex(x => x.UserName)
.IsUnique();
builder.Entity<User>()
.HasMany(x => x.Roles)
.WithMany(x => x.Users);
base.OnModelCreating(builder);
}
}
}
|