111 lines
3.6 KiB
C#
111 lines
3.6 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using MP.Data.DbModels.Mtc;
|
|
using MP.Data.DbModels.Utils;
|
|
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_UtilsContext : 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_UtilsContext()
|
|
{
|
|
}
|
|
|
|
//public MoonPro_UtilsContext(IConfiguration configuration)
|
|
//{
|
|
// _configuration = configuration;
|
|
//}
|
|
|
|
public MoonPro_UtilsContext(DbContextOptions<MoonPro_UtilsContext> options) : base(options)
|
|
{
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Properties
|
|
|
|
|
|
public virtual DbSet<StatsDetailModel> DbSetStatsDet { get; set; }
|
|
public virtual DbSet<StatsAggregatedModel> DbSetStatsAggr { get; set; }
|
|
public virtual DbSet<MtcSetupModel> DbSetMtcSetup { get; set; }
|
|
public virtual DbSet<StatsErrorModel> DbSetStatsError { get; set; }
|
|
public virtual DbSet<StatsStatusCodeModel> DbSetStatusCode { 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.Utils");
|
|
if (!string.IsNullOrEmpty(connString))
|
|
{
|
|
optionsBuilder.UseSqlServer(connString);
|
|
}
|
|
else
|
|
{
|
|
optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=MoonPro_Utils;Trusted_Connection=True;");
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS");
|
|
|
|
// indici tabelle stats
|
|
modelBuilder.Entity<StatsDetailModel>()
|
|
.HasIndex(x => new { x.Destination, x.Type, x.Hour })
|
|
.HasDatabaseName("idx_statsdet_hour_env_type")
|
|
.IsUnique();
|
|
|
|
modelBuilder.Entity<StatsAggregatedModel>()
|
|
.HasIndex(x => new { x.Destination, x.MachineId, x.Hour })
|
|
.HasDatabaseName("idx_statsaggr_env_mach_hour")
|
|
.IsUnique();
|
|
|
|
modelBuilder.Entity<StatsErrorModel>()
|
|
.HasIndex(x => new { x.Destination, x.Type, x.Hour, x.ErrorMessage })
|
|
.HasDatabaseName("idx_statserr_dest_type_hour_err")
|
|
.IsUnique();
|
|
|
|
modelBuilder.Entity<StatsStatusCodeModel>()
|
|
.HasIndex(x => new { x.Destination, x.Type, x.Hour, x.StatusCode })
|
|
.HasDatabaseName("idx_statscode_dest_type_hour_code")
|
|
.IsUnique();
|
|
|
|
OnModelCreatingPartial(modelBuilder);
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
}
|
|
} |