ancora setup progetto identity
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace MagMan.Data
|
||||
|
||||
#region Public Methods
|
||||
|
||||
#if false
|
||||
public static bool checkCreateUser(string username, string pwd, string dbName)
|
||||
{
|
||||
bool answ = false;
|
||||
@@ -64,7 +65,8 @@ namespace MagMan.Data
|
||||
answ = true;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public static async Task<bool> migrateDbMain()
|
||||
{
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace MagMan.Data
|
||||
|
||||
#region Public Methods
|
||||
|
||||
#if false
|
||||
public static bool CheckUser(string nKey, string sKey)
|
||||
{
|
||||
// esecuzione script di install locale
|
||||
@@ -52,6 +53,7 @@ namespace MagMan.Data
|
||||
migrateTask.Wait();
|
||||
return migrateTask.Result;
|
||||
}
|
||||
#endif
|
||||
|
||||
public static bool ExecMigrationMain()
|
||||
{
|
||||
@@ -59,7 +61,7 @@ namespace MagMan.Data
|
||||
var migrateTask = Task.Run(async () => await DbAdmin.migrateDbMain());
|
||||
migrateTask.Wait();
|
||||
return migrateTask.Result;
|
||||
}
|
||||
}
|
||||
|
||||
public static void InitDb(string server, string nKey, string sKey)
|
||||
{
|
||||
|
||||
@@ -7,8 +7,20 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Migrations\UserIdentityDb\**" />
|
||||
<EmbeddedResource Remove="Migrations\UserIdentityDb\**" />
|
||||
<None Remove="Migrations\UserIdentityDb\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="AdminContext.cs" />
|
||||
<Compile Remove="DbModels\UserPrivModel.cs" />
|
||||
<Compile Remove="MailKitEmailSender.cs" />
|
||||
<Compile Remove="MailKitEmailSenderOptions.cs" />
|
||||
<Compile Remove="UserAdminConfiguration.cs" />
|
||||
<Compile Remove="UserData.cs" />
|
||||
<Compile Remove="UserIdentityDbContext.cs" />
|
||||
<Compile Remove="UserRoleConfiguration.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
return;
|
||||
|
||||
reportProcess();
|
||||
await DbAdmin.migrateDbMain();
|
||||
await MagMan.Data.DbAdmin.migrateDbMain();
|
||||
await ReloadData();
|
||||
reportChange();
|
||||
}
|
||||
@@ -55,7 +55,7 @@
|
||||
return;
|
||||
|
||||
reportProcess();
|
||||
await DbAdmin.migrateDbIdentity();
|
||||
await MagMan.User.DbAdmin.migrateDbIdentity();
|
||||
await ReloadData();
|
||||
reportChange();
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using NLog;
|
||||
using Org.BouncyCastle.Pqc.Crypto.Lms;
|
||||
using System.Net.NetworkInformation;
|
||||
using MagMan.Data;
|
||||
using MagMan.Data.DbModels;
|
||||
using MagMan.User;
|
||||
using MagMan.User.DbModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace MagMan.UI.Health
|
||||
@@ -25,7 +25,7 @@ namespace MagMan.UI.Health
|
||||
using (var appDb = new UserIdentityDbContext())
|
||||
{
|
||||
string description = "Try check Table IdentityUsers";
|
||||
List<TableCount> recordList = new List<TableCount>();
|
||||
List<User.DbModels.TableCount> recordList = new List<User.DbModels.TableCount>();
|
||||
var healthCheckData = new Dictionary<string, object>();
|
||||
try
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.25" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.23" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.23" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.23">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.25">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
@@ -51,6 +51,7 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MagMan.Core\MagMan.Core.csproj" />
|
||||
<ProjectReference Include="..\MagMan.Data\MagMan.Data.csproj" />
|
||||
<ProjectReference Include="..\MagMan.User\MagMan.User.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -37,11 +37,12 @@ builder.Services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
|
||||
string dbServerAddr = builder.Configuration["DbConfig:Server"];
|
||||
string nKey = builder.Configuration["DbConfig:nKey"];
|
||||
string sKey = builder.Configuration["DbConfig:sKey"];
|
||||
DbConfig.InitDb(dbServerAddr, nKey, sKey);
|
||||
MagMan.Data.DbConfig.InitDb(dbServerAddr, nKey, sKey);
|
||||
MagMan.User.DbConfig.InitDb(dbServerAddr, nKey, sKey);
|
||||
// inizializzo il DB e creo (se necessario) l'utente
|
||||
DbConfig.CheckUser(nKey, sKey);
|
||||
MagMan.User.DbConfig.CheckUser(nKey, sKey);
|
||||
// verifico se serve applicazione migrazioni
|
||||
DbConfig.ExecMigrationMain();
|
||||
MagMan.Data.DbConfig.ExecMigrationMain();
|
||||
//DbConfig.ExecMigrationIdentity();
|
||||
string connStringDB = DbConfig.CONNECTION_STRING;
|
||||
|
||||
@@ -84,11 +85,11 @@ builder.Services.Configure<DataProtectionTokenProviderOptions>(o =>
|
||||
|
||||
|
||||
|
||||
builder.Services.AddDbContext<UserIdentityDbContext>(options =>
|
||||
builder.Services.AddDbContext<MagMan.User.UserIdentityDbContext>(options =>
|
||||
options.UseSqlServer(connectionString));
|
||||
|
||||
builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
|
||||
.AddEntityFrameworkStores<UserIdentityDbContext>();
|
||||
.AddEntityFrameworkStores<MagMan.User.UserIdentityDbContext>();
|
||||
|
||||
#if false
|
||||
|
||||
|
||||
@@ -8,15 +8,29 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Services\" />
|
||||
<Folder Include="Migrations\" />
|
||||
<Folder Include="DTO\" />
|
||||
<Folder Include="Controllers\" />
|
||||
<Folder Include="DbModels\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.25" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.25" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.25" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.25">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.25" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.25">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NLog" Version="5.2.7" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MagMan.Core\MagMan.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using MagMan.Data;
|
||||
using MagMan.User;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
@@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Migrations.UserIdentityDb
|
||||
namespace MagMan.User.Migrations.UserIdentityDb
|
||||
{
|
||||
[DbContext(typeof(UserIdentityDbContext))]
|
||||
[Migration("20231222165912_CreateIdentitySchema")]
|
||||
@@ -21,7 +21,7 @@ namespace MagMan.Data.Migrations.UserIdentityDb
|
||||
.HasAnnotation("ProductVersion", "6.0.25")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.DbModels.TableCount", b =>
|
||||
modelBuilder.Entity("MagMan.User.DbModels.TableCount", b =>
|
||||
{
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
@@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Migrations.UserIdentityDb
|
||||
namespace MagMan.User.Migrations.UserIdentityDb
|
||||
{
|
||||
public partial class CreateIdentitySchema : Migration
|
||||
{
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using MagMan.Data;
|
||||
using MagMan.User;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MagMan.Data.Migrations.UserIdentityDb
|
||||
namespace MagMan.User.Migrations.UserIdentityDb
|
||||
{
|
||||
[DbContext(typeof(UserIdentityDbContext))]
|
||||
partial class UserIdentityDbContextModelSnapshot : ModelSnapshot
|
||||
@@ -19,7 +19,7 @@ namespace MagMan.Data.Migrations.UserIdentityDb
|
||||
.HasAnnotation("ProductVersion", "6.0.25")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||
|
||||
modelBuilder.Entity("MagMan.Data.DbModels.TableCount", b =>
|
||||
modelBuilder.Entity("MagMan.User.DbModels.TableCount", b =>
|
||||
{
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
Reference in New Issue
Block a user