aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2025-03-01 14:54:51 +0100
committerGitHub <noreply@github.com>2025-03-01 14:54:51 +0100
commit04f7cd6011633f51a4ae50c81141a390d8164bbc (patch)
tree4500fa3452bbede4348074aec15238554104fb48
parent710c253318581d574049abe14eadafb88026dd53 (diff)
parentb0e853070ba368099fdc78d925d4d5675eb00d64 (diff)
Merge pull request #13492 from gnattu/dont-use-returning-clause
Don't use RETURNING clause with EFCore
-rw-r--r--Jellyfin.Server.Implementations/JellyfinDbContext.cs21
1 files changed, 21 insertions, 0 deletions
diff --git a/Jellyfin.Server.Implementations/JellyfinDbContext.cs b/Jellyfin.Server.Implementations/JellyfinDbContext.cs
index 34d9e3960..43ea2bd3c 100644
--- a/Jellyfin.Server.Implementations/JellyfinDbContext.cs
+++ b/Jellyfin.Server.Implementations/JellyfinDbContext.cs
@@ -4,6 +4,8 @@ using Jellyfin.Data.Entities;
using Jellyfin.Data.Entities.Security;
using Jellyfin.Data.Interfaces;
using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+using Microsoft.EntityFrameworkCore.Metadata.Conventions;
using Microsoft.Extensions.Logging;
namespace Jellyfin.Server.Implementations;
@@ -271,4 +273,23 @@ public class JellyfinDbContext(DbContextOptions<JellyfinDbContext> options, ILog
// Configuration for each entity is in its own class inside 'ModelConfiguration'.
modelBuilder.ApplyConfigurationsFromAssembly(typeof(JellyfinDbContext).Assembly);
}
+
+ /// <inheritdoc/>
+ protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
+ {
+ configurationBuilder.Conventions.Add(_ => new DoNotUseReturningClauseConvention());
+ }
+
+ private class DoNotUseReturningClauseConvention : IModelFinalizingConvention
+ {
+ public void ProcessModelFinalizing(
+ IConventionModelBuilder modelBuilder,
+ IConventionContext<IConventionModelBuilder> context)
+ {
+ foreach (var entityType in modelBuilder.Metadata.GetEntityTypes())
+ {
+ entityType.UseSqlReturningClause(false);
+ }
+ }
+ }
}