fix #5940 - add MySQL support to Oqtane 10

This commit is contained in:
sbwalker
2026-01-05 15:49:42 -05:00
parent d6ea610764
commit 86f88c4f7c
5 changed files with 34 additions and 25 deletions

View File

@@ -43,14 +43,6 @@ namespace Oqtane.Repository
{
optionsBuilder.ReplaceService<IMigrationsAssembly, MultiDatabaseMigrationsAssembly>();
// specify the SchemaVersion for .NET Identity as it is not being persisted when using AddIdentityCore()
var services = new ServiceCollection();
services.AddIdentityCore<IdentityUser>(options =>
{
options.Stores.SchemaVersion = IdentitySchemaVersions.Version3;
});
optionsBuilder.UseApplicationServiceProvider(services.BuildServiceProvider());
if (string.IsNullOrEmpty(_connectionString))
{
Tenant tenant = _tenantManager.GetTenant();
@@ -75,6 +67,22 @@ namespace Oqtane.Repository
ActiveDatabase = Activator.CreateInstance(type) as IDatabase;
}
// specify the SchemaVersion for .NET Identity as it is not being persisted when using AddIdentityCore()
var services = new ServiceCollection();
services.AddIdentityCore<IdentityUser>(options =>
{
if (!string.IsNullOrEmpty(_databaseType) && _databaseType.ToLower().Contains("mysql"))
{
// MySQL does not support some of the newer features of .NET Identity (ie. Passkeys)
options.Stores.SchemaVersion = IdentitySchemaVersions.Version2;
}
else
{
options.Stores.SchemaVersion = IdentitySchemaVersions.Version3;
}
});
optionsBuilder.UseApplicationServiceProvider(services.BuildServiceProvider());
if (!string.IsNullOrEmpty(_connectionString) && ActiveDatabase != null)
{
optionsBuilder.UseOqtaneDatabase(ActiveDatabase, _connectionString);