{"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/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Metadata/Internal/DbFunctionParameter.cs#L198-L234","documentation":"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.","triggerScenarios":"Calling .HasParameter(name).HasPropagatesNullability(...) (or the parameter builder's PropagatesNullability setter) on a parameter of a DbFunction that returns IQueryable<T>.","commonSituations":"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.","solutions":["Do not set PropagatesNullability on parameters of table-valued functions.","Guard the configuration so PropagatesNullability is only applied when the function is scalar.","If nullability propagation semantics are needed, convert the function to a scalar function.","Audit parameter configuration loops to skip non-scalar functions."],"exampleFix":"// before\npublic IQueryable<Order> RecentOrders(int days) => /* tvf */;\nmodelBuilder.HasDbFunction(typeof(Ctx).GetMethod(\"RecentOrders\"))\n    .HasParameter(\"days\").HasPropagatesNullability(true); // throws\n\n// after\npublic IQueryable<Order> RecentOrders(int days) => /* tvf */;\nmodelBuilder.HasDbFunction(typeof(Ctx).GetMethod(\"RecentOrders\"));\n// PropagatesNullability only valid on scalar fn params","handlingStrategy":"validation","validationCode":"// Only set PropagatesNullability on parameters of scalar functions\nif (fn.IsScalar)\n{\n    foreach (var p in fn.Parameters)\n        p.Builder.HasPropagatesNullability(true, fromDataAnnotation: true);\n}","typeGuard":"static bool CanPropagateNullability(IDbFunction fn) => fn.IsScalar;","tryCatchPattern":null,"preventionTips":["Skip PropagatesNullability configuration for TVF parameters.","Guard shared parameter-config routines with a function.IsScalar check.","Keep scalar and TVF parameter config in separate code paths."],"tags":["efcore","dbfunction","tvf","parameter","nullable","model-building"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}