114 lines
3.5 KiB
C#
114 lines
3.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
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!;
|
|
public virtual DbSet<CORREOSAREAMS> CORREOSAREAMS { get; set; } = null!;
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
if (!optionsBuilder.IsConfigured)
|
|
{
|
|
//! 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);
|
|
}
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
if (Debugger.IsAttached)
|
|
{
|
|
modelBuilder.HasDefaultSchema("HIMSCAP"); // => AFQ
|
|
}
|
|
else
|
|
{
|
|
modelBuilder.HasDefaultSchema("ADMIN");
|
|
}
|
|
|
|
|
|
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");
|
|
|
|
});
|
|
|
|
modelBuilder.Entity<PERFILPORUSUARIO>(entity =>
|
|
{
|
|
entity.HasKey(e => e.NU_PK_PFLXUSU)
|
|
.HasName("PERFILESPORUSUARIO_PK");
|
|
|
|
entity.ToTable("PERFILESPORUSUARIO");
|
|
|
|
});
|
|
|
|
modelBuilder.Entity<USUARIO>(entity =>
|
|
{
|
|
entity.HasKey(e => e.NU_PK_USUMS)
|
|
.HasName("USUARIOSMS_PK");
|
|
|
|
entity.ToTable("USUARIOSMS");
|
|
|
|
entity.Property(e => e.CL_FIRMA_USUMS).HasColumnType("CLOB");
|
|
});
|
|
|
|
modelBuilder.Entity<CORREOSAREAMS>(entity =>
|
|
{
|
|
entity.HasKey(e => e.NU_PK_CRRMS);
|
|
|
|
entity.ToTable("CORREOSAREAMS");
|
|
|
|
});
|
|
|
|
OnModelCreatingPartial(modelBuilder);
|
|
}
|
|
|
|
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
|
}
|
|
}
|