mirror of
				https://github.com/jellyfin/jellyfin.git
				synced 2025-11-04 03:27:21 -05:00 
			
		
		
		
	Merge pull request #13492 from gnattu/dont-use-returning-clause
Don't use RETURNING clause with EFCore
This commit is contained in:
		
						commit
						04f7cd6011
					
				@ -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);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user