diff --git a/MagMan.Data.Admin/DbAdmin.cs b/MagMan.Data.Admin/DbAdmin.cs index ed8f395..898969d 100644 --- a/MagMan.Data.Admin/DbAdmin.cs +++ b/MagMan.Data.Admin/DbAdmin.cs @@ -60,7 +60,7 @@ namespace MagMan.Data.Admin public static async Task migrateDbIdentity() { bool answ = false; - using (UserIdentityDbContext dbCtx = new UserIdentityDbContext()) + using (IdentityContext dbCtx = new IdentityContext()) { await dbCtx.Database.MigrateAsync(); answ = true; diff --git a/MagMan.Data.Admin/UserIdentityDbContext.cs b/MagMan.Data.Admin/IdentityContext.cs similarity index 70% rename from MagMan.Data.Admin/UserIdentityDbContext.cs rename to MagMan.Data.Admin/IdentityContext.cs index b4685a7..e9e531b 100644 --- a/MagMan.Data.Admin/UserIdentityDbContext.cs +++ b/MagMan.Data.Admin/IdentityContext.cs @@ -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 options) : base(options) + public IdentityContext(DbContextOptions options) : base(options) { - try - { - // se non ci fosse... crea o migra! - Database.Migrate(); - } - catch (Exception exc) - { } } #endregion Public Constructors diff --git a/MagMan.Data.Admin/Migrations/UserIdentityDb/20231222165912_CreateIdentitySchema.Designer.cs b/MagMan.Data.Admin/Migrations/UserIdentityDb/20231222165912_CreateIdentitySchema.Designer.cs index a493e56..06f954f 100644 --- a/MagMan.Data.Admin/Migrations/UserIdentityDb/20231222165912_CreateIdentitySchema.Designer.cs +++ b/MagMan.Data.Admin/Migrations/UserIdentityDb/20231222165912_CreateIdentitySchema.Designer.cs @@ -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 { diff --git a/MagMan.Data.Admin/Migrations/UserIdentityDb/20240111134425_AddUserAndRoles.Designer.cs b/MagMan.Data.Admin/Migrations/UserIdentityDb/20240111134425_AddUserAndRoles.Designer.cs index 6130fde..5a63d55 100644 --- a/MagMan.Data.Admin/Migrations/UserIdentityDb/20240111134425_AddUserAndRoles.Designer.cs +++ b/MagMan.Data.Admin/Migrations/UserIdentityDb/20240111134425_AddUserAndRoles.Designer.cs @@ -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 { diff --git a/MagMan.Data.Admin/Migrations/UserIdentityDb/UserIdentityDbContextModelSnapshot.cs b/MagMan.Data.Admin/Migrations/UserIdentityDb/UserIdentityDbContextModelSnapshot.cs index 25ed42d..76ab3b3 100644 --- a/MagMan.Data.Admin/Migrations/UserIdentityDb/UserIdentityDbContextModelSnapshot.cs +++ b/MagMan.Data.Admin/Migrations/UserIdentityDb/UserIdentityDbContextModelSnapshot.cs @@ -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) diff --git a/MagMan.UI/Health/Checks.cs b/MagMan.UI/Health/Checks.cs index abc6391..959013f 100644 --- a/MagMan.UI/Health/Checks.cs +++ b/MagMan.UI/Health/Checks.cs @@ -23,7 +23,7 @@ namespace MagMan.UI.Health public static async Task DbIdentity(string dbName) { - using (var appDb = new UserIdentityDbContext()) + using (var appDb = new IdentityContext()) { string description = "Try check Table IdentityUsers"; List recordList = new List(); diff --git a/MagMan.UI/Program.cs b/MagMan.UI/Program.cs index d61cafb..ae137ac 100644 --- a/MagMan.UI/Program.cs +++ b/MagMan.UI/Program.cs @@ -89,12 +89,12 @@ builder.Services.Configure(o => // setup MySql var serverVersion = MagMan.Data.Admin.DbConfig.MysqlServerVersion(admConnStr); -builder.Services.AddDbContext(options => +builder.Services.AddDbContext(options => options.UseMySql(connStringDB, serverVersion)); builder.Services.AddDefaultIdentity(options => options.SignIn.RequireConfirmedAccount = true) .AddRoles() - .AddEntityFrameworkStores(); + .AddEntityFrameworkStores(); #if false