aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJPVenson <github@jpb.software>2025-03-01 14:16:02 +0000
committerJPVenson <github@jpb.software>2025-03-01 14:16:02 +0000
commita6b4d124d71c0bbb9dff5f226e65875e03384ab4 (patch)
treeb19c5f63421d8af2fc52a643feb7b510588f62fa /src
parent05f5d19ff45efe1a30a2e33e9aa2366788e8abb9 (diff)
Replicated changes made from #13492
Diffstat (limited to 'src')
-rw-r--r--src/Jellyfin.Database/Jellyfin.Database.Implementations/IJellyfinDatabaseProvider.cs6
-rw-r--r--src/Jellyfin.Database/Jellyfin.Database.Implementations/JellyfinDbContext.cs7
-rw-r--r--src/Jellyfin.Database/Jellyfin.Database.Providers.SqLite/DoNotUseReturningClauseConvention.cs20
-rw-r--r--src/Jellyfin.Database/Jellyfin.Database.Providers.SqLite/SqliteDatabaseProvider.cs6
4 files changed, 39 insertions, 0 deletions
diff --git a/src/Jellyfin.Database/Jellyfin.Database.Implementations/IJellyfinDatabaseProvider.cs b/src/Jellyfin.Database/Jellyfin.Database.Implementations/IJellyfinDatabaseProvider.cs
index b27a88971..cc96792e6 100644
--- a/src/Jellyfin.Database/Jellyfin.Database.Implementations/IJellyfinDatabaseProvider.cs
+++ b/src/Jellyfin.Database/Jellyfin.Database.Implementations/IJellyfinDatabaseProvider.cs
@@ -28,6 +28,12 @@ public interface IJellyfinDatabaseProvider
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>
/// <param name="cancellationToken">The token to abort the operation.</param>
diff --git a/src/Jellyfin.Database/Jellyfin.Database.Implementations/JellyfinDbContext.cs b/src/Jellyfin.Database/Jellyfin.Database.Implementations/JellyfinDbContext.cs
index a0a0f2d0e..c65006c7d 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.cs
new file mode 100644
index 000000000..1ce2420e4
--- /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.cs
index f7fde4989..2364186b1 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 : IJellyfinDatabaseProvider
SqliteConnection.ClearAllPools();
}
+
+ /// <inheritdoc/>
+ public void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
+ {
+ configurationBuilder.Conventions.Add(_ => new DoNotUseReturningClauseConvention());
+ }
}