99 lines
2.8 KiB
C#
99 lines
2.8 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.EntityFrameworkCore.Metadata;
|
|
using Microsoft.Extensions.Configuration;
|
|
using MP.FileData.DatabaseModels;
|
|
using NLog;
|
|
|
|
namespace MP.FileData
|
|
{
|
|
public partial class MoonPro_ProgContext : DbContext
|
|
{
|
|
|
|
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
|
|
|
private IConfiguration _configuration;
|
|
|
|
|
|
public MoonPro_ProgContext(IConfiguration configuration)
|
|
{
|
|
_configuration = configuration;
|
|
}
|
|
|
|
public MoonPro_ProgContext(DbContextOptions<MoonPro_ProgContext> options) : base(options)
|
|
{
|
|
}
|
|
|
|
|
|
public virtual DbSet<AnagArticoli> DbSetArticoli { get; set; }
|
|
public virtual DbSet<Macchine> DbSetMacchine { get; set; }
|
|
|
|
|
|
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
|
|
|
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
if (!optionsBuilder.IsConfigured)
|
|
{
|
|
string connString = _configuration.GetConnectionString("Mp.Stats");
|
|
|
|
optionsBuilder.UseSqlServer(connString);
|
|
//optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=MoonPro_STATS;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("v_UI_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);
|
|
});
|
|
|
|
OnModelCreatingPartial(modelBuilder);
|
|
}
|
|
}
|
|
}
|