using Data; using Microsoft.EntityFrameworkCore; using Models.Models; namespace Models { public class LuminousContext : DbContext { public LuminousContext() { } public LuminousContext(DbContextOptions options) : base(options) { } public DbSet User { get; set; } public DbSet Role { get; set; } public DbSet Product { get; set; } public DbSet Deal { get; set; } public DbSet Stock { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .UseLazyLoadingProxies() .UseSqlServer(Configuration.ConnectionString); } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity() .HasIndex(user => new { user.Name, user.Password }) .IsUnique(true); modelBuilder.Entity() .HasIndex(role => new { role.Name }) .IsUnique(true); modelBuilder.Entity() .HasIndex(product => new { product.Name }) .IsUnique(true); } } }