e5325be058
Rimozione cache da program cs rimozione nuget packages
77 lines
2.0 KiB
C#
77 lines
2.0 KiB
C#
using GWMS.Data.DatabaseModels;
|
|
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using NLog;
|
|
using System;
|
|
|
|
namespace GWMS.Data
|
|
{
|
|
public class UserIdentityDbContext : IdentityDbContext
|
|
{
|
|
#region Public Constructors
|
|
|
|
public UserIdentityDbContext()
|
|
{
|
|
try
|
|
{
|
|
// se non ci fosse... crea o migra!
|
|
Database.Migrate();
|
|
}
|
|
catch (Exception exc)
|
|
{ }
|
|
}
|
|
|
|
public UserIdentityDbContext(DbContextOptions<UserIdentityDbContext> options)
|
|
: base(options)
|
|
{
|
|
#if false
|
|
// se non ci fosse... crea!
|
|
Database.EnsureCreated();
|
|
#endif
|
|
try
|
|
{
|
|
// se non ci fosse... crea o migra!
|
|
Database.Migrate();
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
Log.Error($"Eccezione in UserIdentityDbContext{Environment.NewLine}{exc}");
|
|
}
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Properties
|
|
|
|
public DbSet<TableCount> DbSetCounts { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
string connString = DbConfig.CONNECTION_STRING;
|
|
if (!optionsBuilder.IsConfigured)
|
|
{
|
|
var serverVersion = ServerVersion.AutoDetect(connString);
|
|
optionsBuilder.UseMySql(connString, serverVersion);
|
|
}
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder builder)
|
|
{
|
|
base.OnModelCreating(builder);
|
|
|
|
builder.ApplyConfiguration(new RoleConfiguration());
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
|
|
|
#endregion Private Fields
|
|
}
|
|
} |