forked from sanchezvem/PyroFetes
Fixed all relationship and write errors in all entities
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PyroFetes.Models;
|
||||
using ServiceProvider = PyroFetes.Models.ServiceProvider;
|
||||
|
||||
namespace PyroFetes;
|
||||
|
||||
@@ -13,7 +14,6 @@ public class PyroFetesDbContext : DbContext
|
||||
public DbSet<Communication> Communications { get; set; }
|
||||
public DbSet<Contact> Contacts { get; set; }
|
||||
public DbSet<Customer> Customers { get; set; }
|
||||
public DbSet<CustomerContact> CustomerContacts { get; set; }
|
||||
public DbSet<CustomerType> CustomerTypes { get; set; }
|
||||
public DbSet<Deliverer> Deliverers { get; set; }
|
||||
public DbSet<DeliveryNote> DeliveryNotes { get; set; }
|
||||
@@ -28,7 +28,7 @@ public class PyroFetesDbContext : DbContext
|
||||
public DbSet<ProductColor> ProductColors { get; set; }
|
||||
public DbSet<ProductDelivery> ProductDeliveries { get; set; }
|
||||
public DbSet<ProductEffect> ProductEffects { get; set; }
|
||||
public DbSet<Provider> Providers { get; set; }
|
||||
public DbSet<ServiceProvider> Providers { get; set; }
|
||||
public DbSet<ProviderContact> ProviderContacts { get; set; }
|
||||
public DbSet<ProviderType> ProviderTypes { get; set; }
|
||||
public DbSet<PurchaseOrder> PurchaseOrders { get; set; }
|
||||
@@ -77,20 +77,5 @@ public class PyroFetesDbContext : DbContext
|
||||
.WithMany(w => w.MovementsDestination)
|
||||
.HasForeignKey(m => m.DestinationWarehouseId)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
modelBuilder.Entity<CustomerContact>()
|
||||
.HasKey(cc => new { cc.ContactId, cc.CustomerId });
|
||||
|
||||
modelBuilder.Entity<CustomerContact>()
|
||||
.HasOne(cc => cc.Customer)
|
||||
.WithMany(c => c.CustomerContacts)
|
||||
.HasForeignKey(cc => cc.CustomerId)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
|
||||
modelBuilder.Entity<CustomerContact>()
|
||||
.HasOne(cc => cc.Contact)
|
||||
.WithMany(c => c.CustomerContacts)
|
||||
.HasForeignKey(cc => cc.ContactId)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user