diff --git a/src/EFCore.Relational/Properties/RelationalStrings.Designer.cs b/src/EFCore.Relational/Properties/RelationalStrings.Designer.cs
index 64c5fcd3b60..23ddf163915 100644
--- a/src/EFCore.Relational/Properties/RelationalStrings.Designer.cs
+++ b/src/EFCore.Relational/Properties/RelationalStrings.Designer.cs
@@ -889,6 +889,14 @@ public static string IncompatibleViewNoRelationship(object? view, object? entity
GetString("IncompatibleViewNoRelationship", nameof(view), nameof(entityType), nameof(otherEntityType)),
view, entityType, otherEntityType);
+ ///
+ /// '{name}' was constructed with {argumentCount} arguments, but the nullability was defined for {argumentNullabilityCount} arguments.
+ ///
+ public static string InconsistentNumberOfArguments(object? name, object? argumentCount, object? argumentNullabilityCount)
+ => string.Format(
+ GetString("InconsistentNumberOfArguments", nameof(name), nameof(argumentCount), nameof(argumentNullabilityCount)),
+ name, argumentCount, argumentNullabilityCount);
+
///
/// Cannot set default value '{value}' of type '{valueType}' on property '{property}' of type '{propertyType}' in entity type '{entityType}'.
///
diff --git a/src/EFCore.Relational/Properties/RelationalStrings.resx b/src/EFCore.Relational/Properties/RelationalStrings.resx
index e791520a692..b27917d5d26 100644
--- a/src/EFCore.Relational/Properties/RelationalStrings.resx
+++ b/src/EFCore.Relational/Properties/RelationalStrings.resx
@@ -451,6 +451,9 @@
Cannot use view '{view}' for entity type '{entityType}' since it is being used for entity type '{otherEntityType}' and there is no relationship between their primary keys.
+
+ '{name}' was constructed with {argumentCount} arguments, but the nullability was defined for {argumentNullabilityCount} arguments.
+
Cannot set default value '{value}' of type '{valueType}' on property '{property}' of type '{propertyType}' in entity type '{entityType}'.
diff --git a/src/EFCore.Relational/Query/SqlExpressions/SqlFunctionExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/SqlFunctionExpression.cs
index ff3dcb48ce3..ff782b9a80e 100644
--- a/src/EFCore.Relational/Query/SqlExpressions/SqlFunctionExpression.cs
+++ b/src/EFCore.Relational/Query/SqlExpressions/SqlFunctionExpression.cs
@@ -213,6 +213,17 @@ public SqlFunctionExpression(
IsNullable = nullable;
InstancePropagatesNullability = instancePropagatesNullability;
ArgumentsPropagateNullability = argumentsPropagateNullability?.ToList();
+
+ if (Arguments?.Count != ArgumentsPropagateNullability?.Count)
+ {
+ throw new InvalidOperationException(
+ RelationalStrings.InconsistentNumberOfArguments(
+ name,
+ Arguments?.Count(),
+ ArgumentsPropagateNullability?.Count()
+ )
+ );
+ }
}
///
diff --git a/src/EFCore.Sqlite.Core/Query/Internal/Translators/SqliteRandomTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/Translators/SqliteRandomTranslator.cs
index 5015c54c62b..cc54f6f70b7 100644
--- a/src/EFCore.Sqlite.Core/Query/Internal/Translators/SqliteRandomTranslator.cs
+++ b/src/EFCore.Sqlite.Core/Query/Internal/Translators/SqliteRandomTranslator.cs
@@ -56,7 +56,7 @@ public SqliteRandomTranslator(ISqlExpressionFactory sqlExpressionFactory)
_sqlExpressionFactory.Constant(9223372036854780000.0))
},
nullable: false,
- argumentsPropagateNullability: Enumerable.Empty(),
+ argumentsPropagateNullability: [true],
method.ReturnType)
: null;
}
diff --git a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryMemberTranslator.cs b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryMemberTranslator.cs
index 73866d306b8..f5465515b17 100644
--- a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryMemberTranslator.cs
+++ b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryMemberTranslator.cs
@@ -105,7 +105,7 @@ public SqliteGeometryMemberTranslator(ISqlExpressionFactory sqlExpressionFactory
_sqlExpressionFactory.Constant(" ZM")
},
nullable: true,
- argumentsPropagateNullability: new[] { true },
+ argumentsPropagateNullability: new[] { true, true },
returnType),
new[]
{
@@ -139,7 +139,7 @@ public SqliteGeometryMemberTranslator(ISqlExpressionFactory sqlExpressionFactory
_sqlExpressionFactory.Constant(" ZM")
},
nullable: true,
- argumentsPropagateNullability: new[] { true },
+ argumentsPropagateNullability: new[] { true, true },
typeof(string)),
new[]
{