The Free Software Media System - Server Backend & API
Replicated changes made from #13492
JPVensona6b4d124d71c
diff --git a/src/Jellyfin.Database/Jellyfin.Database.Implementations/IJellyfinDatabaseProvider.cs b/src/Jellyfin.Database/Jellyfin.Database.Implementations/IJellyfinDatabaseProvider.csindex b27a88971d..cc96792e64 100644--- a/src/Jellyfin.Database/Jellyfin.Database.Implementations/IJellyfinDatabaseProvider.cs+++ b/src/Jellyfin.Database/Jellyfin.Database.Implementations/IJellyfinDatabaseProvider.cs@@ -27,6 +27,12 @@ public interface IJellyfinDatabaseProvider/// <param name="modelBuilder">The ModelBuilder from EFCore.</param>void OnModelCreating(ModelBuilder modelBuilder);+ /// <summary>+ /// Will be invoked when EFCore wants to configure its model.+ /// </summary>+ /// <param name="configurationBuilder">The ModelConfigurationBuilder from EFCore.</param>+ void ConfigureConventions(ModelConfigurationBuilder configurationBuilder);+/// <summary>/// If supported this should run any periodic maintaince tasks./// </summary>diff --git a/src/Jellyfin.Database/Jellyfin.Database.Implementations/JellyfinDbContext.cs b/src/Jellyfin.Database/Jellyfin.Database.Implementations/JellyfinDbContext.csindex a0a0f2d0ee..c65006c7d8 100644--- a/src/Jellyfin.Database/Jellyfin.Database.Implementations/JellyfinDbContext.cs+++ b/src/Jellyfin.Database/Jellyfin.Database.Implementations/JellyfinDbContext.cs@@ -272,4 +272,11 @@ 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)+ {+ jellyfinDatabaseProvider.ConfigureConventions(configurationBuilder);+ base.ConfigureConventions(configurationBuilder);+ }}diff --git a/src/Jellyfin.Database/Jellyfin.Database.Providers.SqLite/DoNotUseReturningClauseConvention.cs b/src/Jellyfin.Database/Jellyfin.Database.Providers.SqLite/DoNotUseReturningClauseConvention.csnew file mode 100644index 0000000000..1ce2420e43--- /dev/null+++ b/src/Jellyfin.Database/Jellyfin.Database.Providers.SqLite/DoNotUseReturningClauseConvention.cs@@ -0,0 +1,20 @@+using System;+using Microsoft.EntityFrameworkCore;+using Microsoft.EntityFrameworkCore.Metadata.Builders;+using Microsoft.EntityFrameworkCore.Metadata.Conventions;++namespace Jellyfin.Database.Providers.SqLite;++internal class DoNotUseReturningClauseConvention : IModelFinalizingConvention+{+ /// <inheritdoc/>+ public void ProcessModelFinalizing(+ IConventionModelBuilder modelBuilder,+ IConventionContext<IConventionModelBuilder> context)+ {+ foreach (var entityType in modelBuilder.Metadata.GetEntityTypes())+ {+ entityType.UseSqlReturningClause(false);+ }+ }+}diff --git a/src/Jellyfin.Database/Jellyfin.Database.Providers.SqLite/SqliteDatabaseProvider.cs b/src/Jellyfin.Database/Jellyfin.Database.Providers.SqLite/SqliteDatabaseProvider.csindex f7fde4989e..2364186b12 100644--- a/src/Jellyfin.Database/Jellyfin.Database.Providers.SqLite/SqliteDatabaseProvider.cs+++ b/src/Jellyfin.Database/Jellyfin.Database.Providers.SqLite/SqliteDatabaseProvider.cs@@ -78,4 +78,10 @@ public sealed class SqliteDatabaseProvider : IJellyfinDatabaseProviderSqliteConnection.ClearAllPools();}++ /// <inheritdoc/>+ public void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)+ {+ configurationBuilder.Conventions.Add(_ => new DoNotUseReturningClauseConvention());+ }}