Apigateway/Microservicios/MsUsuarios/Context/ModelContext.cs

151 lines
5.0 KiB
C#
Raw Normal View History

2023-02-02 10:50:02 -05:00
using System;
using System.Collections.Generic;
2023-03-21 18:55:21 -05:00
using System.Diagnostics;
2023-02-02 10:50:02 -05:00
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
namespace MSAdminUsuarios.Context
{
public partial class ModelContext : DbContext
{
public ModelContext()
{
}
public ModelContext(DbContextOptions<ModelContext> options)
: base(options)
{
}
public virtual DbSet<MICROSERVICIO> MICROSERVICIOs { get; set; } = null!;
public virtual DbSet<PERMISO> PERMISOSMs { get; set; } = null!;
public virtual DbSet<PERFIL> PERFILESMs { get; set; } = null!;
public virtual DbSet<PERFILPORUSUARIO> PERFILESPORUSUARIOs { get; set; } = null!;
public virtual DbSet<USUARIO> USUARIOSMs { get; set; } = null!;
2023-11-07 08:35:29 -05:00
public virtual DbSet<CORREOSAREAMS> CORREOSAREAMS { get; set; } = null!;
public virtual DbSet<USUARIOSTEMP> USUARIOSTEMP { get; set; } = null!;
2023-02-02 10:50:02 -05:00
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
2023-03-21 18:55:21 -05:00
//! Requerido! para instanciar ModelContext sin injeccion
var config = new ConfigurationBuilder()
.SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.Development.json", optional: true, reloadOnChange: true)
.Build();
var ConString = config.GetSection("ConnectionStrings:ConString").Get<string>();
optionsBuilder.UseOracle(ConString);
2023-02-02 10:50:02 -05:00
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
//modelBuilder.HasDefaultSchema("HIMSCAP"); // => AFQ
modelBuilder.HasDefaultSchema("ADMIN");
2023-03-21 18:55:21 -05:00
2023-02-02 10:50:02 -05:00
modelBuilder.Entity<MICROSERVICIO>(entity =>
{
entity.HasKey(e => e.NU_PK_MS)
.HasName("MICROSERVICIOS_PK");
entity.ToTable("MICROSERVICIOS");
});
modelBuilder.Entity<PERMISO>(entity =>
{
entity.HasKey(e => e.NU_PK_PMS)
.HasName("PERMISOSMS_PK");
entity.ToTable("PERMISOSMS");
});
modelBuilder.Entity<PERFIL>(entity =>
{
entity.HasKey(e => e.NU_PK_PFL)
.HasName("PERFILESMS_PK");
entity.ToTable("PERFILESMS");
2023-12-06 14:11:53 -05:00
entity.Property(e => e.TX_UUID_PFL).HasMaxLength(40);
2023-02-02 10:50:02 -05:00
});
modelBuilder.Entity<PERFILPORUSUARIO>(entity =>
{
entity.HasKey(e => e.NU_PK_PFLXUSU)
.HasName("PERFILESPORUSUARIO_PK");
entity.ToTable("PERFILESPORUSUARIO");
2023-12-06 14:11:53 -05:00
entity.Property(e => e.TX_UUID_USUMS).HasMaxLength(40);
2023-12-22 15:55:01 -05:00
entity.Property(e => e.TX_UUID_PFL).HasMaxLength(40);
2023-02-02 10:50:02 -05:00
});
modelBuilder.Entity<USUARIO>(entity =>
{
entity.HasKey(e => e.NU_PK_USUMS)
.HasName("USUARIOSMS_PK");
entity.ToTable("USUARIOSMS");
2023-02-14 18:01:33 -05:00
entity.Property(e => e.CL_FIRMA_USUMS).HasColumnType("CLOB");
entity.Property(e => e.TX_UUID_USUMS).HasMaxLength(40);
2023-02-02 10:50:02 -05:00
});
modelBuilder.Entity<CORREOSAREAMS>(entity =>
{
entity.HasKey(e => e.NU_PK_CRRMS);
entity.ToTable("CORREOSAREAMS");
});
2023-11-07 08:35:29 -05:00
modelBuilder.Entity<USUARIOSTEMP>(entity =>
{
entity.HasKey(e => e.NU_PK_USUTMP)
.HasName("USUARIOSTEMP_PK");
entity.ToTable("USUARIOSTEMP");
entity.Property(e => e.NU_PK_USUTMP).HasPrecision(10);
entity.Property(e => e.FE_FINACTIVACION_USUTMP).HasColumnType("DATE");
2023-11-27 08:52:45 -05:00
entity.Property(e => e.FE_INICIOACTIVACION_USUTMP).HasColumnType("DATE");
entity.Property(e => e.NU_ESTADO_USUMS).HasPrecision(10);
2023-11-07 08:35:29 -05:00
2023-11-27 08:52:45 -05:00
entity.Property(e => e.NU_TIPODOC_USUMS).HasPrecision(10);
2023-11-07 08:35:29 -05:00
2023-11-27 08:52:45 -05:00
entity.Property(e => e.TX_CORREO_USUMS).HasMaxLength(200);
2023-11-07 08:35:29 -05:00
2023-11-27 08:52:45 -05:00
entity.Property(e => e.TX_NOMBRE_PVD).HasMaxLength(1999);
2023-11-07 08:35:29 -05:00
2023-11-27 08:52:45 -05:00
entity.Property(e => e.TX_PKDOC_USUMS).HasMaxLength(200);
2023-11-07 08:35:29 -05:00
2023-11-27 08:52:45 -05:00
entity.Property(e => e.TX_PRIMERAPELL_USUMS).HasMaxLength(200);
2023-11-07 08:35:29 -05:00
2023-11-27 08:52:45 -05:00
entity.Property(e => e.TX_PRIMERNOM_USUMS).HasMaxLength(200);
2023-11-07 08:35:29 -05:00
2023-11-27 08:52:45 -05:00
entity.Property(e => e.TX_SEGUNDOAPELL_USUMS).HasMaxLength(200);
2023-11-07 08:35:29 -05:00
2023-11-27 08:52:45 -05:00
entity.Property(e => e.TX_SEGUNDONOM_USUMS).HasMaxLength(200);
2023-11-07 08:35:29 -05:00
2023-11-27 08:52:45 -05:00
entity.Property(e => e.TX_TELEFONO_USUMS).HasMaxLength(200);
2023-11-07 08:35:29 -05:00
});
2023-02-02 10:50:02 -05:00
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
}