{"record":{"id":"7a222499cbdcdb00","repo":"dotnet/efcore","slug":"facet-cannot-be-configured-for-the-parameter","errorCode":null,"errorMessage":"'{facet}' cannot be configured for the parameter '{parameter}' of the stored procedure '{sproc}'.","messagePattern":"'(.+?)' cannot be configured for the parameter '(.+?)' of the stored procedure '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Metadata/Internal/StoredProcedureParameter.cs","lineNumber":207,"sourceCode":"    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    public virtual ParameterDirection Direction\n    {\n        get => _direction ?? ParameterDirection.Input;\n        set => SetDirection(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 ParameterDirection SetDirection(ParameterDirection direction, ConfigurationSource configurationSource)\n    {\n        if (ForRowsAffected)\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.StoredProcedureParameterInvalidConfiguration(\n                    nameof(Direction), Name, ((IReadOnlyStoredProcedure)StoredProcedure).GetStoreIdentifier()?.DisplayName()));\n        }\n\n        if (!IsValid(direction))\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.StoredProcedureParameterInvalidDirection(\n                    direction, Name, ((IReadOnlyStoredProcedure)StoredProcedure).GetStoreIdentifier()?.DisplayName()));\n        }\n\n        _direction = direction;\n\n        _directionConfigurationSource = configurationSource.Max(_directionConfigurationSource);\n\n        return direction;\n    }\n","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Metadata/Internal/StoredProcedureParameter.cs#L189-L225","documentation":"Thrown by StoredProcedureParameter.SetDirection when attempting to configure the Direction of a rows-affected parameter. Rows-affected parameters are always ParameterDirection.Output (set in the constructor at StoredProcedureParameter.cs:45), so EF forbids changing their direction — the error message lists the facet ('Direction') that cannot be configured.","triggerScenarios":"StoredProcedureParameter.cs:205-210: ForRowsAffected is true when SetDirection is called. Produced by obtaining the parameter from AddRowsAffectedParameter() and then assigning .Direction or calling .HasDirection(...).","commonSituations":"Treating the rows-affected parameter like a normal parameter and setting Input/InputOutput; generic parameter-configuration loops that set Direction on every parameter including the rows-affected one.","solutions":["Do not set Direction on a rows-affected parameter — it is implicitly Output.","In generic loops, skip parameters where parameter.ForRowsAffected is true before configuring Direction.","If you need an Input parameter, add it via AddParameter(propertyName) instead of AddRowsAffectedParameter()."],"exampleFix":"// before\nvar p = s.AddRowsAffectedParameter();\np.Direction = ParameterDirection.InputOutput; // throws\n\n// after\nvar p = s.AddRowsAffectedParameter();\n// leave Direction alone; it is Output by default","handlingStrategy":"type-guard","validationCode":"static void SetDirectionSafe(StoredProcedureParameter p, ParameterDirection direction)\n{\n    if (p.ForRowsAffected)\n    {\n        throw new InvalidOperationException(\"Cannot set Direction on a rows-affected parameter.\");\n    }\n    p.Direction = direction;\n}","typeGuard":"static bool CanConfigureDirection(StoredProcedureParameter p) => !p.ForRowsAffected;","tryCatchPattern":null,"preventionTips":["Skip rows-affected parameters in generic direction-config loops.","Treat rows-affected parameters as read-only Output; never reconfigure them."],"tags":["relational","stored-procedure","parameter","rows-affected"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}