diff --git a/src/EFCore.Relational/Query/Internal/RelationalCommandCache.cs b/src/EFCore.Relational/Query/Internal/RelationalCommandCache.cs index d7c6821e5bd..383e21048ec 100644 --- a/src/EFCore.Relational/Query/Internal/RelationalCommandCache.cs +++ b/src/EFCore.Relational/Query/Internal/RelationalCommandCache.cs @@ -97,7 +97,7 @@ public virtual IRelationalCommand GetRelationalCommand([NotNull] IReadOnlyDictio } finally { - _locks.TryRemove(compilationLock, out _); + _locks.TryRemove(cacheKey, out _); } } diff --git a/src/EFCore/Query/Internal/CompiledQueryCache.cs b/src/EFCore/Query/Internal/CompiledQueryCache.cs index 889bfab81ea..0ba038098ee 100644 --- a/src/EFCore/Query/Internal/CompiledQueryCache.cs +++ b/src/EFCore/Query/Internal/CompiledQueryCache.cs @@ -77,7 +77,7 @@ public virtual Func GetOrAddQuery( } finally { - _locks.TryRemove(compilationLock, out _); + _locks.TryRemove(cacheKey, out _); } } }