71 lines
2.2 KiB
C#
71 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata;
|
|
using Microsoft.Extensions.Configuration;
|
|
using NLog;
|
|
using SHERPA.Data.DbModels;
|
|
|
|
// <Auto-Generated>
|
|
// This is here so CodeMaid doesn't reorganize this document
|
|
// </Auto-Generated>
|
|
namespace SHERPA.Data
|
|
{
|
|
public partial class SteamUserContext : DbContext
|
|
{
|
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
|
|
|
private IConfiguration? _configuration;
|
|
|
|
/// <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 SteamUserContext()
|
|
{
|
|
}
|
|
|
|
public SteamUserContext(DbContextOptions<SteamUserContext> options) : base(options)
|
|
{
|
|
}
|
|
|
|
public SteamUserContext(IConfiguration configuration)
|
|
{
|
|
_configuration = configuration;
|
|
}
|
|
|
|
public virtual DbSet<UserDirittiModel> DbSetUserDiritti { get; set; } = null!;
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
if (!optionsBuilder.IsConfigured)
|
|
{
|
|
string connString = _configuration.GetConnectionString("Sherpa.Anagr");
|
|
if (!string.IsNullOrEmpty(connString))
|
|
{
|
|
optionsBuilder.UseSqlServer(connString);
|
|
}
|
|
else
|
|
{
|
|
optionsBuilder.UseSqlServer("Server=W2019-SQL-STEAM;Database=SteamWare_Anagrafica;Trusted_Connection=True;");
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<UserDirittiModel>(entity =>
|
|
{
|
|
entity.HasKey(e => new { e.UserName, e.CdC, e.Modulo, e.Funzione});
|
|
|
|
entity.ToTable("DIRITTI");
|
|
});
|
|
|
|
OnModelCreatingPartial(modelBuilder);
|
|
}
|
|
|
|
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
|
}
|
|
}
|