{"record":{"id":"bffa6142158edcab","repo":"dotnet/efcore","slug":"unsupported-direction-direction-was-specified","errorCode":null,"errorMessage":"Unsupported direction '{direction}' was specified for the parameter '{parameter}' of the stored procedure '{sproc}'.","messagePattern":"Unsupported direction '(.+?)' was specified for the parameter '(.+?)' of the stored procedure '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Metadata/Internal/StoredProcedureParameter.cs","lineNumber":214,"sourceCode":"\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\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 IsValid(ParameterDirection direction)","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Metadata/Internal/StoredProcedureParameter.cs#L196-L232","documentation":"SetDirection rejects ParameterDirection values that are incompatible with the parameter's role. IsValid forbids ReturnValue for any parameter and forbids Output when the parameter carries the original (pre-update) value, since an original-value column must be supplied as input.","triggerScenarios":"Calling .HasDirection(ParameterDirection.ReturnValue) on any parameter, or .HasDirection(ParameterDirection.Output) on a parameter created with originalValue: true (OriginalValueParameter()).","commonSituations":"Assuming every parameter can be Output; mapping audit columns as output when the procedure reads the original row version; scaffolding code that blanket-applies Output to all non-input parameters.","solutions":["Call parameter.IsValid(direction) before SetDirection and skip/adjust on false.","Use Output only on parameters that are not original-value parameters; never use ReturnValue on a stored-procedure parameter.","For rows affected via return value, use RowsAffectedReturned() on the procedure, not a ReturnValue parameter.","Re-check the parameter kind (ForOriginalValue) before assigning direction."],"exampleFix":"// before\nsp.OriginalValueParameter(\"RowVersion\")\n  .HasDirection(ParameterDirection.Output); // throws\n\n// after\nsp.OriginalValueParameter(\"RowVersion\")\n  .HasDirection(ParameterDirection.Input);","handlingStrategy":"validation","validationCode":"if (parameter.IsValid(direction))\n{\n    parameter.HasDirection(direction);\n}","typeGuard":"static bool IsDirectionAllowed(StoredProcedureParameter p, ParameterDirection d)\n    => p.IsValid(d);","tryCatchPattern":null,"preventionTips":["Always call IsValid(direction) before SetDirection.","Remember ReturnValue is never valid for a stored-procedure parameter; use RowsAffectedReturned() on the procedure.","Original-value parameters must be Input."],"tags":["ef-core","stored-procedure","configuration","parameter-direction"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}