{"record":{"id":"64881a9e28114ed7","repo":"dotnet/efcore","slug":"the-original-value-parameter-for-the-property-pr","errorCode":null,"errorMessage":"The original value parameter for the property '{property}' cannot be added to the stored procedure '{sproc}' because another original value parameter for this property already exists.","messagePattern":"The original value parameter for the property '(.+?)' cannot be added to the stored procedure '(.+?)' because another original value parameter for this property already exists\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Metadata/Internal/StoredProcedure.cs","lineNumber":544,"sourceCode":"    ///     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 StoredProcedureParameter? FindOriginalValueParameter(string propertyName)\n        => _originalValueParameters.GetValueOrDefault(propertyName);\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 StoredProcedureParameter AddOriginalValueParameter(string propertyName)\n    {\n        if (_originalValueParameters.ContainsKey(propertyName))\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.StoredProcedureDuplicateOriginalValueParameter(\n                    propertyName, ((IReadOnlyStoredProcedure)this).GetStoreIdentifier()?.DisplayName()));\n        }\n\n        var parameter = new StoredProcedureParameter(this, rowsAffected: false, propertyName, originalValue: true);\n        _parameters.Add(parameter);\n        _originalValueParameters.Add(propertyName, parameter);\n\n        return parameter;\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 StoredProcedureParameter? FindRowsAffectedParameter()","sourceCodeStart":526,"sourceCodeEnd":562,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Metadata/Internal/StoredProcedure.cs#L526-L562","documentation":"Thrown by StoredProcedure.AddOriginalValueParameter when an original-value parameter for the property is already in _originalValueParameters. A property may have at most one original-value parameter on a stored procedure (used for optimistic concurrency on UPDATE).","triggerScenarios":"StoredProcedure.cs:542-547: _originalValueParameters.ContainsKey(propertyName) is true. Produced by calling .OriginalValueParameter(\"X\") / .AddOriginalValueParameter twice, or configuring the same concurrency token's original value twice.","commonSituations":"Declaring .OriginalValueParameter(x => x.RowVersion) twice; mixing lambda and string overloads; re-running sproc configuration without clearing.","solutions":["Guard with FindOriginalValueParameter(propertyName) before adding.","Remove the duplicate original-value parameter configuration.","Configure concurrency-token original values once per sproc."],"exampleFix":"// before\ns.AddOriginalValueParameter(\"RowVersion\");\ns.AddOriginalValueParameter(\"RowVersion\"); // throws\n\n// after\nif (s.FindOriginalValueParameter(\"RowVersion\") == null) s.AddOriginalValueParameter(\"RowVersion\");","handlingStrategy":"validation","validationCode":"static StoredProcedureParameter AddOriginalValueParameterOnce(StoredProcedure sproc, string propertyName)\n    => sproc.FindOriginalValueParameter(propertyName) ?? sproc.AddOriginalValueParameter(propertyName);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Guard AddOriginalValueParameter with FindOriginalValueParameter.","Configure each concurrency-token original value once."],"tags":["relational","stored-procedure","parameter","concurrency","duplicate"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}