using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Data; using System.Linq; namespace Data.SeaHavenIndustries { public class ApplicationDbContext : IdentityDbContext { public ApplicationDbContext(DbContextOptions options) : base(options) { } protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); foreach (var foreignKey in builder.Model.GetEntityTypes().SelectMany (e => e.GetForeignKeys())) { foreignKey.DeleteBehavior = DeleteBehavior.Restrict; } builder.Entity() .HasIndex(t => t.Token) .IsUnique(); builder.Entity() .HasIndex(u => new { u.DispatchId, u.Status }) .IsUnique() .HasFilter("[Status] = 'Pending'"); } public DbSet Categories { get; set; } public DbSet Locations { get; set; } public DbSet Contacts { get; set; } public DbSet workOrders { get; set; } public DbSet