276 lines
9.8 KiB
C#
276 lines
9.8 KiB
C#
using CuentasCobrar.CORE.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace CuentasCobrar.INFRASTRUCTURE.Data;
|
|
public partial class CuentasCobrarContext : DbContext
|
|
{
|
|
public CuentasCobrarContext()
|
|
{
|
|
}
|
|
|
|
public CuentasCobrarContext(DbContextOptions<CuentasCobrarContext> options)
|
|
: base(options)
|
|
{
|
|
}
|
|
|
|
|
|
public virtual DbSet<Banco> Bancos { get; set; }
|
|
|
|
public virtual DbSet<Cliente> Clientes { get; set; }
|
|
|
|
public virtual DbSet<Pais> Paises { get; set; }
|
|
|
|
public virtual DbSet<Rol> Roles { get; set; }
|
|
|
|
public virtual DbSet<Telefono> Telefonos { get; set; }
|
|
|
|
public virtual DbSet<TipoIdentificacion> TipoIdentificaciones { get; set; }
|
|
|
|
public virtual DbSet<TipoTelefono> TipoTelefonos { get; set; }
|
|
|
|
public virtual DbSet<Usuario> Usuarios { get; set; }
|
|
|
|
// Agregados manualmente
|
|
public virtual DbSet<Moneda> Monedas { get; set; }
|
|
public virtual DbSet<Pago> Pagos { get; set; }
|
|
public virtual DbSet<TipoDocumento> TiposDocumento { get; set; }
|
|
public virtual DbSet<TipoPago> TiposPago { get; set; }
|
|
public virtual DbSet<Factura> Facturas { get; set; }
|
|
public virtual DbSet<RolDeUsuario> RolesDeUsuarios { get; set; }
|
|
public virtual DbSet<PagoContieneFactura> PagoContieneFacturas { get; set; }
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
|
|
modelBuilder.Entity<Banco>(entity =>
|
|
{
|
|
entity.HasKey(e => e.IdBanco).HasName("PK__Banco__2D3F553E3E070539");
|
|
|
|
entity.ToTable("Banco", "catalogo");
|
|
|
|
entity.Property(e => e.Nombre).HasMaxLength(255);
|
|
entity.Property(e => e.Nomenclatura).HasMaxLength(100);
|
|
});
|
|
|
|
modelBuilder.Entity<Cliente>(entity =>
|
|
{
|
|
entity.HasKey(c => c.NoIdentificacion).HasName("PK__Cliente__85CD349F66C6A8E0");
|
|
|
|
entity.ToTable("Cliente", "global");
|
|
|
|
entity.Property(c => c.Apellido1).HasMaxLength(255);
|
|
entity.Property(c => c.Apellido2).HasMaxLength(255);
|
|
entity.Property(c => c.Correo)
|
|
.HasMaxLength(200)
|
|
.IsUnicode(false);
|
|
entity.Property(c => c.Direccion)
|
|
.HasMaxLength(500)
|
|
.IsUnicode(false);
|
|
entity.Property(c => c.Nombre).HasMaxLength(255);
|
|
|
|
entity.HasOne(c => c.IdPaisNacionalidadNavigation)
|
|
.WithMany(p => p.Clientes)
|
|
.HasForeignKey(c => c.IdPaisNacionalidad)
|
|
.OnDelete(DeleteBehavior.ClientSetNull)
|
|
.HasConstraintName("FK__Cliente__IdPaisN__47FBA9D6");
|
|
|
|
entity.HasOne(c => c.IdTipoIdentificacionNavigation)
|
|
.WithMany(ti => ti.Clientes)
|
|
.HasForeignKey(c => c.IdTipoIdentificacion)
|
|
.OnDelete(DeleteBehavior.ClientSetNull)
|
|
.HasConstraintName("FK__Cliente__IdTipoI__4707859D");
|
|
});
|
|
|
|
modelBuilder.Entity<PagoContieneFactura>(entity =>
|
|
{
|
|
entity.HasKey(pcf => new { pcf.NoReciboPago, pcf.ConsecutivoFactura }).HasName("PK__PagoCont__8B63A4E4F1870F3F");
|
|
|
|
entity.ToTable("PagoContieneFactura", "global");
|
|
|
|
entity.HasOne(pcf => pcf.NoReciboNavigation)
|
|
.WithMany(p => p.PagoContieneFacturas)
|
|
.HasForeignKey(pcf => pcf.NoReciboPago)
|
|
.HasConstraintName("FK__PagoConti__NoRec__3572E547");
|
|
|
|
entity.HasOne(pcf => pcf.ConsecutivoFacturaNavigation)
|
|
.WithMany(p => p.PagoContieneFacturas)
|
|
.HasForeignKey(pcf => pcf.ConsecutivoFactura)
|
|
.HasConstraintName("FK__PagoConti__Conse__347EC10E");
|
|
});
|
|
|
|
modelBuilder.Entity<Pais>(entity =>
|
|
{
|
|
entity.HasKey(e => e.IdPais).HasName("PK__Pais__FC850A7BC674C915");
|
|
|
|
entity.ToTable("Pais", "catalogo");
|
|
|
|
entity.Property(e => e.CodigoDeArea)
|
|
.HasMaxLength(4)
|
|
.IsUnicode(false);
|
|
entity.Property(e => e.Nombre).HasMaxLength(50);
|
|
entity.Property(e => e.Nacionalidad).HasMaxLength(100);
|
|
});
|
|
|
|
modelBuilder.Entity<Pago>(entity =>
|
|
{
|
|
entity.HasKey(c => c.NoRecibo).HasName("[PK__Pago__7688EB130D619E62]");
|
|
|
|
entity.ToTable("Pago", "global");
|
|
|
|
entity.HasOne(p => p.IdMonedaNavigation)
|
|
.WithMany(m => m.Pagos)
|
|
.HasForeignKey(p => p.IdMoneda)
|
|
.HasConstraintName("FK__Pago__IdMoneda__5DB5E0CB");
|
|
|
|
entity.HasOne(p => p.IdTipoPagoNavigation)
|
|
.WithMany(tp => tp.Pagos)
|
|
.HasForeignKey(p => p.IdTipoPago)
|
|
.HasConstraintName("FK__Pago__IdTipoPago__5EAA0504");
|
|
|
|
entity.HasOne(p => p.IdBancoNavigation)
|
|
.WithMany(b => b.Pagos)
|
|
.HasForeignKey(p => p.IdBanco)
|
|
.HasConstraintName("FK__Pago__IdBanco__5CC1BC92");
|
|
|
|
});
|
|
|
|
modelBuilder.Entity<Factura>(entity =>
|
|
{
|
|
entity.HasKey(c => c.Consecutivo).HasName("[PK__Factura__AB810F674E340669]");
|
|
|
|
entity.ToTable("Factura", "global");
|
|
|
|
entity.HasOne(f => f.IdMonedaNavigation)
|
|
.WithMany(m => m.Facturas)
|
|
.HasForeignKey(f => f.IdMoneda)
|
|
.HasConstraintName("FK__Factura__IdMoned__627A95E8");
|
|
|
|
entity.HasOne(f => f.IdTipoDocumentoNavigation)
|
|
.WithMany(td => td.Facturas)
|
|
.HasForeignKey(f => f.IdTipoDocumento)
|
|
.HasConstraintName("FK__Factura__IdTipoD__636EBA21");
|
|
|
|
entity.HasOne(f => f.NoIdentificacionClienteNavigation)
|
|
.WithMany(c => c.Facturas)
|
|
.HasForeignKey(f => f.NoIdentificacionCliente)
|
|
.HasConstraintName("FK__Factura__NoIdent__618671AF");
|
|
|
|
});
|
|
|
|
modelBuilder.Entity<Rol>(entity =>
|
|
{
|
|
entity.HasKey(e => e.IdRol).HasName("PK__Rol__2A49584C04DA73D1");
|
|
|
|
entity.ToTable("Rol", "catalogo");
|
|
|
|
entity.Property(e => e.Descripcion).HasMaxLength(255);
|
|
});
|
|
|
|
modelBuilder.Entity<Telefono>(entity =>
|
|
{
|
|
entity.HasKey(e => e.IdTelefono).HasName("PK__Telefono__9B8AC75359567F35");
|
|
|
|
entity.ToTable("Telefono", "global");
|
|
|
|
entity.Property(e => e.Numero).HasMaxLength(25);
|
|
entity.Property(e => e.NoIdentificacionCliente).HasMaxLength(25);
|
|
|
|
entity.HasOne(t => t.NoIdentificacionClienteNavigation)
|
|
.WithMany(c => c.Telefonos)
|
|
.HasForeignKey(t => t.NoIdentificacionCliente)
|
|
.HasConstraintName("FK__Telefono__NoIden__4BCC3ABA");
|
|
|
|
entity.HasOne(t => t.IdTipoTelefonoNavigation)
|
|
.WithMany(tp => tp.Telefonos)
|
|
.HasForeignKey(t => t.IdTipoTelefono)
|
|
.HasConstraintName("FK__Telefono__IdTipo__4AD81681");
|
|
});
|
|
|
|
modelBuilder.Entity<TipoIdentificacion>(entity =>
|
|
{
|
|
entity.HasKey(e => e.IdTipoIdentificacion).HasName("PK__TipoIden__F521C6A8FE1D2C50");
|
|
|
|
entity.ToTable("TipoIdentificacion", "catalogo");
|
|
|
|
entity.Property(e => e.Descripcion).HasMaxLength(50);
|
|
});
|
|
|
|
modelBuilder.Entity<TipoTelefono>(entity =>
|
|
{
|
|
entity.HasKey(e => e.IdTipoTelefono).HasName("PK__TipoTele__6FA65CBF794852A9");
|
|
|
|
entity.ToTable("TipoTelefono", "catalogo");
|
|
|
|
entity.Property(e => e.Descripcion).HasMaxLength(50);
|
|
});
|
|
|
|
modelBuilder.Entity<Moneda>(entity =>
|
|
{
|
|
entity.HasKey(m => m.IdMoneda).HasName("PK__Moneda__AA690671C7075783");
|
|
|
|
entity.ToTable("Moneda", "catalogo");
|
|
|
|
entity.Property(m => m.Descripcion).HasMaxLength(255);
|
|
entity.Property(m => m.Simbolo).HasMaxLength(1);
|
|
});
|
|
|
|
modelBuilder.Entity<TipoDocumento>(entity =>
|
|
{
|
|
entity.HasKey(td => td.IdTipoDocumento).HasName("PK__TipoDocu__3AB3332F9C573562");
|
|
|
|
entity.ToTable("TipoDocumento", "catalogo");
|
|
|
|
entity.Property(td => td.Descripcion).HasMaxLength(255);
|
|
});
|
|
|
|
modelBuilder.Entity<TipoPago>(entity =>
|
|
{
|
|
entity.HasKey(tp => tp.IdTipoPago).HasName("PK__TipoPago__EB0AA9E7D5EF4FF4");
|
|
|
|
entity.ToTable("TipoPago", "catalogo");
|
|
|
|
entity.Property(tp => tp.Descripcion).HasMaxLength(255);
|
|
});
|
|
|
|
modelBuilder.Entity<RolDeUsuario>(entity =>
|
|
{
|
|
entity.HasKey(ar => new { ar.IdUsuario, ar.IdRol }).HasName("PK__RolDeUsu__89C12A131E4152F0");
|
|
|
|
entity.ToTable("RolDeUsuario", "global");
|
|
|
|
entity.Property(arp => arp.DescripcionDeRol).HasMaxLength(255);
|
|
|
|
entity.HasOne(ru => ru.RolNavigation)
|
|
.WithMany(r => r.RolesdeUsuario)
|
|
.HasForeignKey(ru => ru.IdRol)
|
|
.HasConstraintName("FK__RolDeUsua__IdRol__30242045");
|
|
|
|
entity.HasOne(ru => ru.UsuarioNavigation)
|
|
.WithMany(p => p.RolesdeUsuario)
|
|
.HasForeignKey(ru => ru.IdUsuario)
|
|
.HasConstraintName("FK__RolDeUsua__IdUsu__2F2FFC0C");
|
|
|
|
});
|
|
|
|
modelBuilder.Entity<Usuario>(entity =>
|
|
{
|
|
entity.HasKey(e => e.IdUsuario).HasName("PK__Usuario__5B65BF97E1E9D674 ");
|
|
|
|
entity.ToTable("Usuario", "catalogo");
|
|
|
|
entity.Property(e => e.IdUsuario)
|
|
.HasMaxLength(20)
|
|
.IsUnicode(false);
|
|
entity.Property(e => e.Apellido1).HasMaxLength(255);
|
|
entity.Property(e => e.Apellido2).HasMaxLength(255);
|
|
entity.Property(e => e.Correo)
|
|
.HasMaxLength(200)
|
|
.IsUnicode(false);
|
|
entity.Property(e => e.Nombre).HasMaxLength(255);
|
|
});
|
|
|
|
OnModelCreatingPartial(modelBuilder);
|
|
}
|
|
|
|
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
|
}
|