blob: e8eb5fb39a15ad5a3ee9461ae74cef969559aa2a (
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
27
28
29
30
31
32
33
34
35
|
using System;
using DevHive.Data.Models;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
namespace DevHive.Data
{
public class DevHiveContext : IdentityDbContext<User, Role, Guid>
{
public DevHiveContext(DbContextOptions options)
: base(options) { }
public DbSet<Technology> Technologies { get; set; }
public DbSet<Language> Languages { get; set; }
protected override void OnModelCreating(ModelBuilder builder)
{
builder.Entity<User>()
.HasIndex(x => x.UserName)
.IsUnique();
builder.Entity<User>()
.HasMany(x => x.Roles);
builder.Entity<User>()
.HasMany(x => x.Friends);
builder.Entity<Role>()
.HasIndex(x => x.Id)
.IsUnique();
base.OnModelCreating(builder);
}
}
}
|