line-gestao-api/Data/AppDbContext.cs

21 lines
502 B
C#

using Microsoft.EntityFrameworkCore;
using line_gestao_api.Models;
namespace line_gestao_api.Data;
public class AppDbContext : DbContext
{
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
public DbSet<User> Users => Set<User>();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<User>()
.HasIndex(u => u.Email)
.IsUnique();
}
}