using Microsoft.EntityFrameworkCore; using PyroFetes.Models; using ServiceProvider = PyroFetes.Models.ServiceProvider; namespace PyroFetes; public class PyroFetesDbContext : DbContext { // Entities public DbSet Availabilities { get; set; } public DbSet Brands { get; set; } public DbSet Classifications { get; set; } public DbSet Colors { get; set; } public DbSet Communications { get; set; } public DbSet Contacts { get; set; } public DbSet Customers { get; set; } public DbSet CustomerTypes { get; set; } public DbSet Deliverers { get; set; } public DbSet DeliveryNotes { get; set; } public DbSet Effects { get; set; } public DbSet ExperienceLevels { get; set; } public DbSet HistoryOfApprovals { get; set; } public DbSet Materials { get; set; } public DbSet Movements { get; set; } public DbSet Prices { get; set; } public DbSet Products { get; set; } public DbSet ProductCategories { get; set; } public DbSet ProductColors { get; set; } public DbSet ProductDeliveries { get; set; } public DbSet ProductEffects { get; set; } public DbSet Providers { get; set; } public DbSet ProviderContacts { get; set; } public DbSet ProviderTypes { get; set; } public DbSet PurchaseOrders { get; set; } public DbSet PurchaseProducts { get; set; } public DbSet Quotations { get; set; } public DbSet QuotationProducts { get; set; } public DbSet Settings { get; set; } public DbSet Shows { get; set; } public DbSet Sounds { get; set; } public DbSet SoundCategories { get; set; } public DbSet SoundTimecodes { get; set; } public DbSet Staffs { get; set; } public DbSet StaffAvailabilities { get; set; } public DbSet StaffContacts { get; set; } public DbSet StaffHistoryOfApprovals { get; set; } public DbSet Suppliers { get; set; } public DbSet Trucks { get; set; } public DbSet Users { get; set; } public DbSet Warehouses { get; set; } public DbSet WarehouseProducts { get; set; } public DbSet Logins { get; set; } // Database configuration protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { string connectionString = "Server=romaric-thibault.fr;" + "Database=PyroFetes;" + "User Id=pyrofetes;" + "Password=Crablike8-Fringe-Swimmable;" + "TrustServerCertificate=true;"; optionsBuilder.UseSqlServer(connectionString); } // Models customization protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity() .HasOne(m => m.SourceWarehouse) .WithMany(w => w.MovementsSource) .HasForeignKey(m => m.SourceWarehouseId) .OnDelete(DeleteBehavior.Restrict); modelBuilder.Entity() .HasOne(m => m.DestinationWarehouse) .WithMany(w => w.MovementsDestination) .HasForeignKey(m => m.DestinationWarehouseId) .OnDelete(DeleteBehavior.Restrict); modelBuilder.Entity() .HasOne(mw => mw.Material) .WithMany(m => m.MaterialWarehouses) .HasForeignKey(mw => mw.MaterialId) .OnDelete(DeleteBehavior.Restrict); modelBuilder.Entity() .HasOne(mw => mw.Warehouse) .WithMany(w => w.MaterialWarehouses) .HasForeignKey(mw => mw.WarehouseId) .OnDelete(DeleteBehavior.Restrict); } }