Rename + pulizia metodi IdentContext
This commit is contained in:
@@ -60,7 +60,7 @@ namespace MagMan.Data.Admin
|
||||
public static async Task<bool> migrateDbIdentity()
|
||||
{
|
||||
bool answ = false;
|
||||
using (UserIdentityDbContext dbCtx = new UserIdentityDbContext())
|
||||
using (IdentityContext dbCtx = new IdentityContext())
|
||||
{
|
||||
await dbCtx.Database.MigrateAsync();
|
||||
answ = true;
|
||||
|
||||
@@ -9,31 +9,16 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Admin
|
||||
{
|
||||
public class UserIdentityDbContext : IdentityDbContext
|
||||
public class IdentityContext : IdentityDbContext
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public UserIdentityDbContext()
|
||||
public IdentityContext()
|
||||
{
|
||||
DbConfig.InitDb("localhost", "aaa", "bbb");
|
||||
try
|
||||
{
|
||||
// se non ci fosse... crea o migra!
|
||||
Database.Migrate();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{ }
|
||||
}
|
||||
|
||||
public UserIdentityDbContext(DbContextOptions<UserIdentityDbContext> options) : base(options)
|
||||
public IdentityContext(DbContextOptions<IdentityContext> options) : base(options)
|
||||
{
|
||||
try
|
||||
{
|
||||
// se non ci fosse... crea o migra!
|
||||
Database.Migrate();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{ }
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
Generated
+1
-1
@@ -10,7 +10,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace MagMan.Data.Admin.Migrations.UserIdentityDb
|
||||
{
|
||||
[DbContext(typeof(UserIdentityDbContext))]
|
||||
[DbContext(typeof(IdentityContext))]
|
||||
[Migration("20231222165912_CreateIdentitySchema")]
|
||||
partial class CreateIdentitySchema
|
||||
{
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace MagMan.Data.Admin.Migrations.UserIdentityDb
|
||||
{
|
||||
[DbContext(typeof(UserIdentityDbContext))]
|
||||
[DbContext(typeof(IdentityContext))]
|
||||
[Migration("20240111134425_AddUserAndRoles")]
|
||||
partial class AddUserAndRoles
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace MagMan.Data.Admin.Migrations.UserIdentityDb
|
||||
{
|
||||
[DbContext(typeof(UserIdentityDbContext))]
|
||||
[DbContext(typeof(IdentityContext))]
|
||||
partial class UserIdentityDbContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace MagMan.UI.Health
|
||||
|
||||
public static async Task<HealthCheckResult> DbIdentity(string dbName)
|
||||
{
|
||||
using (var appDb = new UserIdentityDbContext())
|
||||
using (var appDb = new IdentityContext())
|
||||
{
|
||||
string description = "Try check Table IdentityUsers";
|
||||
List<MagMan.Data.Admin.DbModels.TableCount> recordList = new List<MagMan.Data.Admin.DbModels.TableCount>();
|
||||
|
||||
@@ -89,12 +89,12 @@ builder.Services.Configure<DataProtectionTokenProviderOptions>(o =>
|
||||
|
||||
// setup MySql
|
||||
var serverVersion = MagMan.Data.Admin.DbConfig.MysqlServerVersion(admConnStr);
|
||||
builder.Services.AddDbContext<UserIdentityDbContext>(options =>
|
||||
builder.Services.AddDbContext<IdentityContext>(options =>
|
||||
options.UseMySql(connStringDB, serverVersion));
|
||||
|
||||
builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
|
||||
.AddRoles<IdentityRole>()
|
||||
.AddEntityFrameworkStores<UserIdentityDbContext>();
|
||||
.AddEntityFrameworkStores<IdentityContext>();
|
||||
|
||||
#if false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user