155 lines
4.6 KiB
C#
155 lines
4.6 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using MP.Core.DTO;
|
|
using MP.Data.DbModels;
|
|
using NLog;
|
|
using System;
|
|
|
|
#nullable disable
|
|
// <Auto-Generated>
|
|
// This is here so CodeMaid doesn't reorganize this document
|
|
// </Auto-Generated>
|
|
namespace MP.Data
|
|
{
|
|
public partial class MoonPro_FluxContext : DbContext
|
|
{
|
|
#region Private Fields
|
|
|
|
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
|
|
|
private IConfiguration _configuration;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Public Constructors
|
|
|
|
/// <summary>
|
|
/// Indispensabile x prima generazione migrations EFCore
|
|
/// </summary>
|
|
|
|
[Obsolete("This constructor should never be used directly, and is only needed to generate entityframework stuff. Connection string can be adapted as pleased.")]
|
|
public MoonPro_FluxContext()
|
|
{
|
|
}
|
|
|
|
public MoonPro_FluxContext(IConfiguration configuration)
|
|
{
|
|
_configuration = configuration;
|
|
}
|
|
|
|
public MoonPro_FluxContext(DbContextOptions<MoonPro_FluxContext> options) : base(options)
|
|
{
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Properties
|
|
|
|
|
|
public virtual DbSet<DbSizeModel> DbSetDbSize { get; set; }
|
|
public virtual DbSet<AnagArticoliModel> DbSetArticoli { get; set; }
|
|
public virtual DbSet<MacchineModel> DbSetMacchine { get; set; }
|
|
public virtual DbSet<FluxLogModel> DbSetFluxLog { get; set; }
|
|
public virtual DbSet<DossierModel> DbSetDossiers { get; set; }
|
|
public virtual DbSet<ParetoFluxLogDTO> DbSetParetoFluxLog { get; set; }
|
|
public virtual DbSet<ConfFluxModel> DbSetConfFlux { 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.Flux");
|
|
if (!string.IsNullOrEmpty(connString))
|
|
{
|
|
optionsBuilder.UseSqlServer(connString);
|
|
}
|
|
else
|
|
{
|
|
optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=MoonPro_FluxData;Trusted_Connection=True;");
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS");
|
|
|
|
modelBuilder.Entity<AnagArticoliModel>(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<MacchineModel>(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<FluxLogModel>(entity =>
|
|
{
|
|
entity.HasKey(e => new { e.IdxMacchina, e.dtEvento, e.CodFlux });
|
|
|
|
});
|
|
|
|
modelBuilder.Entity<ParetoFluxLogDTO>(entity =>
|
|
{
|
|
entity.HasKey(e => new { e.IdxMacchina, e.CodFlux });
|
|
});
|
|
|
|
modelBuilder.Entity<ConfFluxModel>(entity =>
|
|
{
|
|
entity.HasKey(e => new { e.IdxMacchina, e.CodFlux });
|
|
|
|
});
|
|
|
|
|
|
OnModelCreatingPartial(modelBuilder);
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
}
|
|
} |