322 lines
11 KiB
C#
322 lines
11 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata;
|
|
using Microsoft.Extensions.Configuration;
|
|
using MP.Data.DatabaseModels;
|
|
using NLog;
|
|
|
|
#nullable disable
|
|
// <Auto-Generated>
|
|
// This is here so CodeMaid doesn't reorganize this document
|
|
// </Auto-Generated>
|
|
namespace MP.Data
|
|
{
|
|
public partial class MoonProContext : DbContext
|
|
{
|
|
#region Private Fields
|
|
|
|
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
|
|
|
private IConfiguration _configuration;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Public Constructors
|
|
|
|
public MoonProContext(IConfiguration configuration)
|
|
{
|
|
_configuration = configuration;
|
|
}
|
|
|
|
public MoonProContext(DbContextOptions<MoonProContext> options) : base(options)
|
|
{
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Properties
|
|
|
|
public virtual DbSet<StatsAnagArticoli> DbSetStatArticoli { get; set; }
|
|
public virtual DbSet<AnagArticoli> DbSetArticoli { get; set; }
|
|
public virtual DbSet<Macchine> DbSetMacchine { get; set; }
|
|
public virtual DbSet<MappaStatoExpl> DbSetMSE { get; set; }
|
|
public virtual DbSet<ConfigModel> DbSetConfig { get; set; }
|
|
public virtual DbSet<AnagGruppi> DbSetAnagGruppi { get; set; }
|
|
public virtual DbSet<ListValues> DbSetListValues { get; set; }
|
|
public virtual DbSet<LinkMenu> DbSetLinkMenu { get; set; }
|
|
public virtual DbSet<ODLModel> DbSetODL { get; set; }
|
|
public virtual DbSet<PODLModel> DbSetPODL { get; set; }
|
|
public virtual DbSet<FluxLog> DbSetFluxLog { get; set; }
|
|
public virtual DbSet<DossierModel> DbSetDossiers { get; set; }
|
|
public virtual DbSet<StatODLModel> DbSetStatOdl { get; set; }
|
|
public virtual DbSet<StatoProdModel> DbSetStatoProd { get; set; }
|
|
public virtual DbSet<EventListModel> DbSetEvList { get; set; }
|
|
public virtual DbSet<VocabolarioModel> DbSetVocabolario { get; set; }
|
|
public virtual DbSet<AnagOperatoriModel> DbOperatori { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Private Methods
|
|
|
|
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
|
|
|
#endregion Private Methods
|
|
|
|
#region Protected Methods
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
if (!optionsBuilder.IsConfigured)
|
|
{
|
|
string connString = _configuration.GetConnectionString("Mp.Data");
|
|
if (string.IsNullOrEmpty(connString))
|
|
{
|
|
connString = _configuration.GetConnectionString("Mp.Mon");
|
|
}
|
|
if (string.IsNullOrEmpty(connString))
|
|
{
|
|
connString = _configuration.GetConnectionString("Mp.STATS");
|
|
}
|
|
|
|
optionsBuilder.UseSqlServer(connString);
|
|
//optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=MoonPro;Trusted_Connection=True;");
|
|
}
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS");
|
|
|
|
modelBuilder.Entity<StatsAnagArticoli>(entity =>
|
|
{
|
|
entity.HasKey(e => e.CodArticolo);
|
|
|
|
entity.ToView("v_UI_AnagArticoli");
|
|
|
|
entity.Property(e => e.CodArticolo)
|
|
.IsRequired()
|
|
.HasMaxLength(50);
|
|
|
|
entity.Property(e => e.DescArticolo)
|
|
.IsRequired()
|
|
.HasMaxLength(250);
|
|
|
|
entity.Property(e => e.Disegno)
|
|
.IsRequired()
|
|
.HasMaxLength(50);
|
|
|
|
entity.Property(e => e.Tipo)
|
|
.IsRequired()
|
|
.HasMaxLength(50);
|
|
});
|
|
modelBuilder.Entity<AnagArticoli>(entity =>
|
|
{
|
|
entity.HasKey(e => e.CodArticolo);
|
|
|
|
entity.ToView("AnagArticoli");
|
|
|
|
entity.Property(e => e.CodArticolo)
|
|
.IsRequired()
|
|
.HasMaxLength(50);
|
|
|
|
entity.Property(e => e.DescArticolo)
|
|
.IsRequired()
|
|
.HasMaxLength(250);
|
|
|
|
entity.Property(e => e.Disegno)
|
|
.IsRequired()
|
|
.HasMaxLength(50);
|
|
|
|
entity.Property(e => e.Tipo)
|
|
.IsRequired()
|
|
.HasMaxLength(50);
|
|
|
|
entity.Property(e => e.Azienda)
|
|
.IsRequired()
|
|
.HasMaxLength(50);
|
|
});
|
|
|
|
modelBuilder.Entity<Macchine>(entity =>
|
|
{
|
|
entity.HasKey(e => e.IdxMacchina);
|
|
|
|
entity.ToView("Macchine");
|
|
|
|
entity.Property(e => e.CodMacchina).HasMaxLength(50);
|
|
|
|
entity.Property(e => e.Descrizione).HasMaxLength(50);
|
|
|
|
entity.Property(e => e.IdxMacchina)
|
|
.IsRequired()
|
|
.HasMaxLength(50);
|
|
|
|
entity.Property(e => e.Nome).HasMaxLength(50);
|
|
});
|
|
|
|
modelBuilder.Entity<MappaStatoExpl>(entity =>
|
|
{
|
|
entity.HasKey(e => e.RowNum);
|
|
|
|
entity.ToTable("MappaStatoExpl");
|
|
|
|
entity.Property(e => e.CodArticolo)
|
|
.HasMaxLength(50)
|
|
.HasDefaultValueSql("('-')");
|
|
|
|
entity.Property(e => e.CodMacchina).HasMaxLength(50);
|
|
|
|
entity.Property(e => e.DataInizioOdl)
|
|
.HasColumnType("datetime")
|
|
.HasColumnName("DataInizioODL");
|
|
|
|
entity.Property(e => e.DescrizioneStato)
|
|
.HasMaxLength(50)
|
|
.HasDefaultValueSql("('n.d.')");
|
|
|
|
entity.Property(e => e.Disegno)
|
|
.HasMaxLength(50)
|
|
.HasDefaultValueSql("('')");
|
|
|
|
entity.Property(e => e.Durata)
|
|
.HasColumnName("durata")
|
|
.HasDefaultValueSql("((0))");
|
|
|
|
entity.Property(e => e.IdxMacchina).HasMaxLength(50);
|
|
|
|
entity.Property(e => e.IdxOdl).HasColumnName("idxODL");
|
|
|
|
entity.Property(e => e.IdxStato)
|
|
.HasColumnName("idxStato")
|
|
.HasDefaultValueSql("((0))");
|
|
|
|
entity.Property(e => e.LastUpdate)
|
|
.HasColumnType("datetime")
|
|
.HasColumnName("lastUpdate");
|
|
|
|
entity.Property(e => e.Nome).HasMaxLength(50);
|
|
|
|
entity.Property(e => e.PezziConf).HasDefaultValueSql("((0))");
|
|
|
|
entity.Property(e => e.PezziProd).HasDefaultValueSql("((0))");
|
|
|
|
entity.Property(e => e.Semaforo)
|
|
.HasMaxLength(50)
|
|
.HasDefaultValueSql("('')");
|
|
|
|
entity.Property(e => e.TCAssegnato)
|
|
.HasColumnType("decimal(18, 8)")
|
|
.HasColumnName("TCAssegnato")
|
|
.HasDefaultValueSql("((1))");
|
|
|
|
entity.Property(e => e.TCEff)
|
|
.HasColumnType("decimal(18, 8)")
|
|
.HasColumnName("TCEff")
|
|
.HasDefaultValueSql("((0))");
|
|
|
|
entity.Property(e => e.TCEffRT)
|
|
.HasColumnType("decimal(18, 8)")
|
|
.HasColumnName("TCEffRT")
|
|
.HasDefaultValueSql("((0))");
|
|
|
|
entity.Property(e => e.TCLav)
|
|
.HasColumnType("decimal(18, 8)")
|
|
.HasColumnName("TCLav")
|
|
.HasDefaultValueSql("((0))");
|
|
|
|
entity.Property(e => e.TCLavRT)
|
|
.HasColumnType("decimal(18, 8)")
|
|
.HasColumnName("TCLavRT")
|
|
.HasDefaultValueSql("((0))");
|
|
|
|
entity.Property(e => e.TCMedio)
|
|
.HasColumnType("decimal(18, 8)")
|
|
.HasColumnName("TCMedio")
|
|
.HasDefaultValueSql("((0))");
|
|
|
|
entity.Property(e => e.TCMedioRt)
|
|
.HasColumnType("decimal(18, 8)")
|
|
.HasColumnName("TCMedioRT")
|
|
.HasDefaultValueSql("((0))");
|
|
|
|
entity.Property(e => e.TempoAuto)
|
|
.HasColumnType("decimal(18, 8)")
|
|
.HasDefaultValueSql("((0))");
|
|
|
|
entity.Property(e => e.TempoOn)
|
|
.HasColumnType("decimal(18, 8)")
|
|
.HasDefaultValueSql("((0))");
|
|
|
|
entity.Property(e => e.TempoRun)
|
|
.HasColumnType("decimal(18, 8)")
|
|
.HasDefaultValueSql("((0))");
|
|
|
|
entity.Property(e => e.Url)
|
|
.HasMaxLength(250)
|
|
.HasColumnName("url");
|
|
});
|
|
modelBuilder.Entity<ConfigModel>(entity =>
|
|
{
|
|
entity.HasKey(e => e.Chiave);
|
|
|
|
entity.ToTable("Config");
|
|
|
|
entity.Property(e => e.Chiave)
|
|
.HasMaxLength(50)
|
|
.HasColumnName("chiave");
|
|
|
|
entity.Property(e => e.Note).HasColumnName("note");
|
|
|
|
entity.Property(e => e.Valore).HasColumnName("valore");
|
|
|
|
entity.Property(e => e.ValoreStd)
|
|
.HasColumnName("valoreStd")
|
|
.HasComment("Valore di default/riferimento per la variabile");
|
|
});
|
|
modelBuilder.Entity<AnagGruppi>(entity =>
|
|
{
|
|
entity.HasKey(e => e.CodGruppo);
|
|
|
|
entity.Property(e => e.CodGruppo)
|
|
.HasMaxLength(50)
|
|
.HasColumnName("CodGruppo");
|
|
|
|
entity.Property(e => e.TipoGruppo)
|
|
.HasMaxLength(50)
|
|
.HasColumnName("TipoGruppo");
|
|
|
|
entity.Property(e => e.DescrGruppo)
|
|
.HasMaxLength(250)
|
|
.HasColumnName("DescrGruppo");
|
|
|
|
entity.Property(e => e.SelEnabled)
|
|
.HasColumnName("SelEnabled");
|
|
|
|
});
|
|
modelBuilder.Entity<ListValues>(entity =>
|
|
{
|
|
entity.HasKey(e => new { e.TableName, e.FieldName, e.value });
|
|
|
|
});
|
|
modelBuilder.Entity<FluxLog>(entity =>
|
|
{
|
|
entity.HasKey(e => new { e.IdxMacchina, e.dtEvento, e.CodFlux });
|
|
|
|
});
|
|
|
|
modelBuilder.Entity<EventListModel>(entity =>
|
|
{
|
|
entity.HasKey(e => new { e.IdxMacchina, e.InizioStato, e.IdxTipo });
|
|
|
|
});
|
|
modelBuilder.Entity<VocabolarioModel>(entity =>
|
|
{
|
|
entity.HasKey(e => new { e.Lingua, e.Lemma });
|
|
|
|
});
|
|
|
|
OnModelCreatingPartial(modelBuilder);
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
}
|
|
} |