fix #5916 - PostgreSQL failing to install on .NET 10
This commit is contained in:
@@ -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,36 +109,40 @@ 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())
|
||||||
{
|
{
|
||||||
var tableName = entity.GetTableName();
|
// the IdentityPasskeyData entity was introduced in .NET 10 and is not mapped to a database table so should be ignored
|
||||||
if (tableName.StartsWith("AspNetUser"))
|
if (entity.ClrType.Name != "IdentityPasskeyData")
|
||||||
{
|
{
|
||||||
// replace table name
|
var tableName = entity.GetTableName();
|
||||||
entity.SetTableName(RewriteName(entity.GetTableName()));
|
if (tableName.StartsWith("AspNetUser"))
|
||||||
|
|
||||||
// replace column names
|
|
||||||
foreach(var property in entity.GetProperties())
|
|
||||||
{
|
{
|
||||||
property.SetColumnName(RewriteName(property.Name));
|
// replace table name
|
||||||
}
|
entity.SetTableName(RewriteName(entity.GetTableName()));
|
||||||
|
|
||||||
// replace key names
|
// replace column names
|
||||||
foreach(var key in entity.GetKeys())
|
foreach (var property in entity.GetProperties())
|
||||||
{
|
{
|
||||||
key.SetName(RewriteName(key.GetName()));
|
property.SetColumnName(RewriteName(property.Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
// replace foreign key names
|
// replace key names
|
||||||
foreach (var key in entity.GetForeignKeys())
|
foreach (var key in entity.GetKeys())
|
||||||
{
|
{
|
||||||
key.PrincipalKey.SetName(RewriteName(key.PrincipalKey.GetName()));
|
key.SetName(RewriteName(key.GetName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// replace index names
|
// replace foreign key names
|
||||||
foreach (var index in entity.GetIndexes())
|
foreach (var key in entity.GetForeignKeys())
|
||||||
{
|
{
|
||||||
index.SetDatabaseName(RewriteName(index.GetDatabaseName()));
|
key.PrincipalKey.SetName(RewriteName(key.PrincipalKey.GetName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// replace index names
|
||||||
|
foreach (var index in entity.GetIndexes())
|
||||||
|
{
|
||||||
|
index.SetDatabaseName(RewriteName(index.GetDatabaseName()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user