fix #5916 - PostgreSQL failing to install on .NET 10

This commit is contained in:
sbwalker
2025-12-23 12:09:16 -05:00
parent 6733299290
commit aca70dd6c7

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Data; using System.Data;
using System.Globalization; using System.Globalization;
using System.Linq;
using EFCore.NamingConventions.Internal; using EFCore.NamingConventions.Internal;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
@@ -108,7 +109,10 @@ namespace Oqtane.Database.PostgreSQL
public override void UpdateIdentityStoreTableNames(ModelBuilder builder) public override void UpdateIdentityStoreTableNames(ModelBuilder builder)
{ {
foreach(var entity in builder.Model.GetEntityTypes()) foreach (var entity in builder.Model.GetEntityTypes())
{
// the IdentityPasskeyData entity was introduced in .NET 10 and is not mapped to a database table so should be ignored
if (entity.ClrType.Name != "IdentityPasskeyData")
{ {
var tableName = entity.GetTableName(); var tableName = entity.GetTableName();
if (tableName.StartsWith("AspNetUser")) if (tableName.StartsWith("AspNetUser"))
@@ -117,13 +121,13 @@ namespace Oqtane.Database.PostgreSQL
entity.SetTableName(RewriteName(entity.GetTableName())); entity.SetTableName(RewriteName(entity.GetTableName()));
// replace column names // replace column names
foreach(var property in entity.GetProperties()) foreach (var property in entity.GetProperties())
{ {
property.SetColumnName(RewriteName(property.Name)); property.SetColumnName(RewriteName(property.Name));
} }
// replace key names // replace key names
foreach(var key in entity.GetKeys()) foreach (var key in entity.GetKeys())
{ {
key.SetName(RewriteName(key.GetName())); key.SetName(RewriteName(key.GetName()));
} }
@@ -142,6 +146,7 @@ namespace Oqtane.Database.PostgreSQL
} }
} }
} }
}
public override DbContextOptionsBuilder UseDatabase(DbContextOptionsBuilder optionsBuilder, string connectionString) public override DbContextOptionsBuilder UseDatabase(DbContextOptionsBuilder optionsBuilder, string connectionString)
{ {