diff --git a/src/EFCore.Relational/Query/QuerySqlGenerator.cs b/src/EFCore.Relational/Query/QuerySqlGenerator.cs index 2d953aa6d13..7dd6cbf143d 100644 --- a/src/EFCore.Relational/Query/QuerySqlGenerator.cs +++ b/src/EFCore.Relational/Query/QuerySqlGenerator.cs @@ -602,11 +602,14 @@ protected override Expression VisitSqlParameter(SqlParameterExpression sqlParame // data twice. // Note that if the type mapping differs, we do send the same data twice (e.g. the same string may be sent once as Unicode, once as // non-Unicode). - var parameter = _relationalCommandBuilder.Parameters.FirstOrDefault(p => - p.InvariantName == parameterName - && p is TypeMappedRelationalParameter typeMappedRelationalParameter - && typeMappedRelationalParameter.RelationalTypeMapping.StoreType == sqlParameterExpression.TypeMapping!.StoreType - && typeMappedRelationalParameter.RelationalTypeMapping.Converter == sqlParameterExpression.TypeMapping!.Converter); + var parameter = _relationalCommandBuilder.Parameters.FirstOrDefault( + p => + p.InvariantName == parameterName + && p is TypeMappedRelationalParameter typeMappedRelationalParameter + && string.Equals( + typeMappedRelationalParameter.RelationalTypeMapping.StoreType, sqlParameterExpression.TypeMapping!.StoreType, + StringComparison.OrdinalIgnoreCase) + && typeMappedRelationalParameter.RelationalTypeMapping.Converter == sqlParameterExpression.TypeMapping!.Converter); if (parameter is null) {