-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppDbContext.cs
28 lines (22 loc) · 898 Bytes
/
AppDbContext.cs
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
using HostAccessibilityCheckingSite.Data.Models;
using Microsoft.EntityFrameworkCore;
using System;
namespace HostAccessibilityCheckingSite
{
public class AppDbContext : DbContext
{
public DbSet<User> Users { get; set; }
public DbSet<PingResult> PingHistory { get; set; }
public DbSet<SiteSettings> Sites { get; set; }
public DbSet<Relation> Relations { get; set; }
public AppDbContext() => Database.EnsureCreated();
protected override void OnModelCreating(ModelBuilder builder)
{
builder.Entity<User>().HasAlternateKey(u => u.Username);
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer("Server=(localdb)\\mssqllocaldb;Database=HostChekingDb;Trusted_Connection=True;MultipleActiveResultSets=true");
}
}
}