using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using ElectroShop.DAL.Entities;
namespace ElectroShop.DAL
{
    public class ElectroShopDBContext : IdentityDbContext<ApplicationUser>
    {
        public ElectroShopDBContext(DbContextOptions options) : base(options)
        {
            Database.EnsureCreated();
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<ElectronicComponentCathegory>()
                .HasIndex(p => new { p.Name })
                .IsUnique(true);

            base.OnModelCreating(modelBuilder);
        }

        public DbSet<ElectronicComponent> ElectronicComponents { get; set; }

        public DbSet<ElectronicComponentCathegory> ElectronicComponentCathegories { get; set; }
    }
}
