dotnet/efcore · error · InvalidOperationException
'PropagatesNullability' cannot be set on parameter
Error message
'PropagatesNullability' cannot be set on parameter '{parameterName}' of DbFunction '{functionName}' since function does not represent a scalar function. What it means
Nullability propagation (whether a NULL parameter makes the result NULL) is only meaningful for scalar DbFunctions. DbFunctionParameter.SetPropagatesNullability throws when called on a parameter of a non-scalar (TVF) function, because row-set results do not have a single NULL outcome.
Solutions
- Remove the PropagatesNullability call from any parameter belonging to a TVF DbFunction.
- If nullability propagation is required, change the function to a scalar return so per-parameter propagation is valid.
Example fix
// before
public IQueryable<Order> Search(string term) => throw new NotSupportedException();
modelBuilder.HasDbFunction(typeof(AppDb).GetMethod(nameof(Search)))
.HasParameter("term").PropagatesNullability();
// after
modelBuilder.HasDbFunction(typeof(AppDb).GetMethod(nameof(Search)));
// parameters of a TVF cannot be marked as propagating nullability Defensive patterns
Strategy: validation
Validate before calling
var fn = modelBuilder.HasDbFunction(typeof(AppDb).GetMethod(nameof(AppDb.Search))!).Metadata;
if (!fn.IsScalar)
{
return; // do not configure PropagatesNullability on TVF parameters
} Type guard
static bool ParameterSupportsNullability(IReadOnlyDbFunction fn) => fn.IsScalar;
Prevention
- Branch per-parameter configuration by fn.IsScalar before applying PropagatesNullability.
- Keep scalar and TVF DbFunction setup in separate helper methods.
When it happens
Trigger: Calling HasParameter(name).PropagatesNullability(...) or SetPropagatesNullability on a parameter of a method that returns IQueryable<T>; common when sharing configuration helpers between scalar and TVF functions.
Common situations: Building a fluent helper that configures all DbFunctions uniformly and including PropagatesNullability; refactor converting a scalar function to a TVF while leaving per-parameter configuration in place.
Related errors
- 'IsNullable' cannot be set on DbFunction
- Custom translation cannot be set on the DbFunction
- The DbFunction ' ' does not have a parameter named ' '.
- The DbFunction ' ' has an invalid return type ' '…
- The DbFunction ' ' defined on type ' ' must be either a…
AI-assisted analysis of dotnet/efcore@3a2006ef56 (2026-08-11).
Data as JSON: /api/errors/c52f4e070f6a8a99.
Report an issue: GitHub.
Appendix: source
Thrown at src/EFCore.Relational/Metadata/Internal/DbFunctionParameter.cs:216
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool PropagatesNullability
{
get => _propagatesNullability;
set => SetPropagatesNullability(value, ConfigurationSource.Explicit);
}
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool SetPropagatesNullability(bool propagatesNullability, ConfigurationSource configurationSource)
{
if (!Function.IsScalar)
{
throw new InvalidOperationException(
RelationalStrings.NonScalarFunctionParameterCannotPropagatesNullability(Name, Function.Name));
}
_propagatesNullability = propagatesNullability;
_propagatesNullabilityConfigurationSource = configurationSource.Max(_storeTypeConfigurationSource);
return propagatesNullability;
}
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual ConfigurationSource? GetPropagatesNullabilityConfigurationSource()
=> _propagatesNullabilityConfigurationSource;
View on GitHub (pinned to 3a2006ef56)