24 lines
641 B
C#
24 lines
641 B
C#
using Microsoft.EntityFrameworkCore;
|
|
using SessionZeroBackend.Models;
|
|
|
|
namespace SessionZeroBackend;
|
|
|
|
public class ApplicationDbContext : DbContext
|
|
{
|
|
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) {}
|
|
|
|
public DbSet<User> Users { get; set; }
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
base.OnModelCreating(modelBuilder);
|
|
|
|
modelBuilder.Entity<User>()
|
|
.HasIndex(u => u.Email)
|
|
.IsUnique();
|
|
|
|
modelBuilder.Entity<User>()
|
|
.HasIndex(u => u.Username)
|
|
.IsUnique();
|
|
}
|
|
} |