Files
mapo-core/MP.Data/MoonProContext.cs
T
2022-04-13 20:06:19 +02:00

232 lines
7.4 KiB
C#

using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.Extensions.Configuration;
using MP.Data.DatabaseModels;
using NLog;
#nullable disable
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<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; }
#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.Mon");
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<AnagArticoli>(entity =>
{
entity.HasNoKey();
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<Macchine>(entity =>
{
entity.HasNoKey();
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");
});
OnModelCreatingPartial(modelBuilder);
}
#endregion Protected Methods
}
}