{"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/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Metadata/Internal/StoredProcedureParameter.cs#L196-L232","documentation":"Thrown by StoredProcedureParameter.SetDirection when the requested ParameterDirection is not valid for that parameter. IsValid rejects ParameterDirection.ReturnValue for all parameters, and ParameterDirection.Output for original-value parameters (ForOriginalValue == true), because output original-value parameters have no meaningful semantics.","triggerScenarios":"StoredProcedureParameter.cs:212-217: IsValid(direction) is false. Produced by setting an original-value parameter's Direction to Output, or setting any parameter's Direction to ReturnValue.","commonSituations":"Configuring a concurrency token's original-value parameter as Output; trying to use ReturnValue via the Direction facet instead of the dedicated rows-affected/return-value API; scaffolding then nudging directions.","solutions":["For original-value parameters, keep Direction as Input (the default) or InputOutput — never Output.","Never use ParameterDirection.ReturnValue; use ReturnsRowsAffected() / the rows-affected API for return-value semantics.","If you need an output parameter, add it via AddParameter (not AddOriginalValueParameter)."],"exampleFix":"// before\nvar p = s.AddOriginalValueParameter(\"RowVersion\");\np.Direction = ParameterDirection.Output; // throws - original value can't be output\n\n// after\nvar p = s.AddOriginalValueParameter(\"RowVersion\");\np.Direction = ParameterDirection.Input;","handlingStrategy":"validation","validationCode":"static void SetDirectionValidated(StoredProcedureParameter p, ParameterDirection direction)\n{\n    if (direction == ParameterDirection.ReturnValue)\n        throw new InvalidOperationException(\"ReturnValue is not allowed; use the rows-affected API.\");\n    if (direction == ParameterDirection.Output && p.ForOriginalValue == true)\n        throw new InvalidOperationException(\"Original-value parameters cannot be Output.\");\n    p.Direction = direction;\n}","typeGuard":"static bool IsValidDirection(StoredProcedureParameter p, ParameterDirection d)\n    => d != ParameterDirection.ReturnValue && !(d == ParameterDirection.Output && p.ForOriginalValue == true);","tryCatchPattern":null,"preventionTips":["Never assign ParameterDirection.ReturnValue via the Direction facet.","Keep original-value (concurrency) parameters as Input."],"tags":["relational","stored-procedure","parameter","direction"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}