dotnet/efcore · error · InvalidOperationException

'PropagatesNullability' cannot be set on parameter '{paramet

Error message

'PropagatesNullability' cannot be set on parameter '{parameterName}' of DbFunction '{functionName}' since function does not represent a scalar function.

What it means

Thrown by DbFunctionParameter.SetPropagatesNullability when the owning function is not scalar (it is a table-valued function returning IQueryable<T>). Nullability propagation is a property of scalar function parameters — for TVFs the concept does not apply, so EF rejects the configuration.

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 dbf9771522)

Solutions

  1. Do not set PropagatesNullability on parameters of table-valued functions.
  2. Guard the configuration so PropagatesNullability is only applied when the function is scalar.
  3. If nullability propagation semantics are needed, convert the function to a scalar function.
  4. Audit parameter configuration loops to skip non-scalar functions.

Example fix

// before
public IQueryable<Order> RecentOrders(int days) => /* tvf */;
modelBuilder.HasDbFunction(typeof(Ctx).GetMethod("RecentOrders"))
    .HasParameter("days").HasPropagatesNullability(true); // throws

// after
public IQueryable<Order> RecentOrders(int days) => /* tvf */;
modelBuilder.HasDbFunction(typeof(Ctx).GetMethod("RecentOrders"));
// PropagatesNullability only valid on scalar fn params
Defensive patterns

Strategy: validation

Validate before calling

// Only set PropagatesNullability on parameters of scalar functions
if (fn.IsScalar)
{
    foreach (var p in fn.Parameters)
        p.Builder.HasPropagatesNullability(true, fromDataAnnotation: true);
}

Type guard

static bool CanPropagateNullability(IDbFunction fn) => fn.IsScalar;

Prevention

When it happens

Trigger: Calling .HasParameter(name).HasPropagatesNullability(...) (or the parameter builder's PropagatesNullability setter) on a parameter of a DbFunction that returns IQueryable<T>.

Common situations: Generic DbFunction configuration helpers iterate parameters and set PropagatesNullability on all of them, hitting a TVF. Or a developer copies scalar-function parameter config onto a TVF parameter.

Related errors


AI-assisted analysis of dotnet/efcore@dbf9771522 (2026-08-06). Data as JSON: /api/errors/c52f4e070f6a8a99. Report an issue: GitHub.