{"record":{"id":"c52f4e070f6a8a99","repo":"dotnet/efcore","slug":"propagatesnullability-cannot-be-set-on-parameter","errorCode":null,"errorMessage":"'PropagatesNullability' cannot be set on parameter '{parameterName}' of DbFunction '{functionName}' since function does not represent a scalar function.","messagePattern":"'PropagatesNullability' cannot be set on parameter '(.+?)' of DbFunction '(.+?)' since function does not represent a scalar function\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Metadata/Internal/DbFunctionParameter.cs","lineNumber":216,"sourceCode":"    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    public virtual bool PropagatesNullability\n    {\n        get => _propagatesNullability;\n        set => SetPropagatesNullability(value, ConfigurationSource.Explicit);\n    }\n\n    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    public virtual bool SetPropagatesNullability(bool propagatesNullability, ConfigurationSource configurationSource)\n    {\n        if (!Function.IsScalar)\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.NonScalarFunctionParameterCannotPropagatesNullability(Name, Function.Name));\n        }\n\n        _propagatesNullability = propagatesNullability;\n        _propagatesNullabilityConfigurationSource = configurationSource.Max(_storeTypeConfigurationSource);\n\n        return propagatesNullability;\n    }\n\n    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    public virtual ConfigurationSource? GetPropagatesNullabilityConfigurationSource()\n        => _propagatesNullabilityConfigurationSource;\n","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Metadata/Internal/DbFunctionParameter.cs#L198-L234","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\npublic IQueryable<Order> Search(string term) => throw new NotSupportedException();\nmodelBuilder.HasDbFunction(typeof(AppDb).GetMethod(nameof(Search)))\n    .HasParameter(\"term\").PropagatesNullability();\n\n// after\nmodelBuilder.HasDbFunction(typeof(AppDb).GetMethod(nameof(Search)));\n// parameters of a TVF cannot be marked as propagating nullability","handlingStrategy":"validation","validationCode":"var fn = modelBuilder.HasDbFunction(typeof(AppDb).GetMethod(nameof(AppDb.Search))!).Metadata;\nif (!fn.IsScalar)\n{\n    return; // do not configure PropagatesNullability on TVF parameters\n}","typeGuard":"static bool ParameterSupportsNullability(IReadOnlyDbFunction fn) => fn.IsScalar;","tryCatchPattern":null,"preventionTips":["Branch per-parameter configuration by fn.IsScalar before applying PropagatesNullability.","Keep scalar and TVF DbFunction setup in separate helper methods."],"tags":["relational","dbfunctions","parameters","nullability","table-valued-functions"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}