{"record":{"id":"d6583fcbb8273333","repo":"dotnet/efcore","slug":"the-parameter-for-the-property-property-cannot","errorCode":null,"errorMessage":"The parameter for the property '{property}' cannot be added to the stored procedure '{sproc}' because another parameter for this property already exists.","messagePattern":"The parameter for the property '(.+?)' cannot be added to the stored procedure '(.+?)' because another parameter for this property already exists\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Metadata/Internal/StoredProcedure.cs","lineNumber":513,"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? FindParameter(string propertyName)\n        => _currentValueParameters.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 AddParameter(string propertyName)\n    {\n        if (_currentValueParameters.ContainsKey(propertyName))\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.StoredProcedureDuplicateParameter(\n                    propertyName, ((IReadOnlyStoredProcedure)this).GetStoreIdentifier()?.DisplayName()));\n        }\n\n        var parameter = new StoredProcedureParameter(this, rowsAffected: false, propertyName, originalValue: false);\n        _parameters.Add(parameter);\n        _currentValueParameters.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? FindOriginalValueParameter(string propertyName)","sourceCodeStart":495,"sourceCodeEnd":531,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Metadata/Internal/StoredProcedure.cs#L495-L531","documentation":"Thrown when AddParameter(propertyName) is called for a property that already has a current-value parameter on the stored procedure mapping. A property may have at most one current-value parameter.","triggerScenarios":"StoredProcedure.AddParameter(propertyName) when _currentValueParameters.ContainsKey(propertyName). Triggered by calling HasParameter(p => p.X) twice, or mixing fluent calls that both resolve to a current-value parameter for the same property.","commonSituations":"Copy/paste of HasParameter calls; combining attribute-based stored procedure mapping with fluent configuration; building parameters programmatically without checking existence; refactoring mappings that double-add the same property.","solutions":["Check whether the parameter already exists (StoredProcedure.FindParameter(propertyName)) before adding.","Remove the duplicate HasParameter call.","If you need original-value semantics, use AddOriginalValueParameter instead of a second AddParameter.","Build the mapping once, declaratively, to avoid programmatic double-add."],"exampleFix":"// before\ninsertSproc.HasParameter(p => p.Name);\ninsertSproc.HasParameter(p => p.Name); // throws\n\n// after: declare each parameter once\ninsertSproc.HasParameter(p => p.Name);","handlingStrategy":"validation","validationCode":"// Before adding a parameter, check existence.\nif (sproc.FindParameter(propertyName) is null)\n    sproc.HasParameter(propertyName);\nelse\n    Console.WriteLine($\"Parameter for '{propertyName}' already exists; skipping.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build stored procedure mappings declaratively in one place rather than incrementally.","Avoid combining attribute-based and fluent stored-procedure configuration for the same parameters.","Use FindParameter before programmatic AddParameter calls."],"tags":["ef-core","relational-metadata","stored-procedure","parameter","duplicate"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}