SessionZero/SessionZeroBackend/ApplicationDbContext.cs
2025-03-27 23:33:23 -05:00

23 lines
725 B
C#

using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using SessionZeroBackend.Models;
namespace SessionZeroBackend;
public class ApplicationDbContext : IdentityDbContext<IdentityUser>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) {}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<IdentityUser>(entity =>
{
entity.ToTable("Users");
entity.HasIndex(u => u.Email).IsUnique();
entity.HasIndex(u => u.UserName).IsUnique();
});
}
}