{"record":{"id":"11d5528334af90c0","repo":"dotnet/efcore","slug":"the-parameter-parameter-cannot-be-added-to-the","errorCode":null,"errorMessage":"The parameter '{parameter}' cannot be added to the stored procedure '{sproc}' because another parameter with this name already exists.","messagePattern":"The parameter '(.+?)' cannot be added to the stored procedure '(.+?)' because another parameter with this name already exists\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":782,"sourceCode":"                                            property.GetAfterSaveBehavior()));\n                                }\n\n                                break;\n\n                            case StoreObjectType.DeleteStoredProcedure:\n                                break;\n\n                            default:\n                                Check.DebugFail(\"Unexpected stored procedure type: \" + storeObjectIdentifier.StoreObjectType);\n                                break;\n                        }\n                    }\n                }\n            }\n\n            if (!parameterNames.Add(parameter.Name))\n            {\n                throw new InvalidOperationException(\n                    RelationalStrings.StoredProcedureDuplicateParameterName(\n                        parameter.Name, storeObjectIdentifier.DisplayName()));\n            }\n\n            if (parameter.PropertyName == null)\n            {\n                continue;\n            }\n\n            switch (storeObjectIdentifier.StoreObjectType)\n            {\n                case StoreObjectType.InsertStoredProcedure:\n                case StoreObjectType.UpdateStoredProcedure:\n                    if (parameter.Direction != ParameterDirection.Input\n                        && !storeGeneratedProperties.Remove(property!.Name))\n                    {\n                        if (sproc.Parameters.Any(p => p.PropertyName == property.Name\n                                && p.ForOriginalValue != parameter.ForOriginalValue","sourceCodeStart":764,"sourceCodeEnd":800,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L764-L800","documentation":"Thrown when two parameters on the same stored procedure share the same store parameter name. The validator tracks names in a HashSet and rejects a duplicate add. Each parameter must have a unique store name within a single sproc, including the implicit current-value and original-value forms of the same property.","triggerScenarios":"Two .HasParameter(\"Name\") calls; an original-value and current-value parameter of the same property resolving to the same store name without explicit renaming.","commonSituations":"Explicitly naming two parameters identically; declaring both a current and original value parameter for a property using the same default name.","solutions":["Give one parameter a distinct explicit name via the HasParameter(\"uniqueName\") overload.","Remove the duplicate parameter.","Ensure original-value and current-value parameters for the same property use different store names."],"exampleFix":"// before\nsp.HasParameter(\"RowVersion\");\nsp.HasOriginalValueParameter(\"RowVersion\"); // same default name\n\n// after\nsp.HasParameter(\"RowVersion\");\nsp.HasOriginalValueParameter(\"RowVersion_Original\");","handlingStrategy":"validation","validationCode":"foreach (var et in modelBuilder.Model.GetEntityTypes())\n{\n    foreach (var s in new[] { et.GetInsertStoredProcedure(), et.GetUpdateStoredProcedure(), et.GetDeleteStoredProcedure() }.Where(s => s != null))\n    {\n        var seen = new HashSet<string>();\n        foreach (var p in s.Parameters)\n            if (!seen.Add(p.Name)) throw new InvalidOperationException($\"Duplicate param {p.Name} on {s.GetStoreIdentifier().Name}\");\n    }\n}","typeGuard":null,"tryCatchPattern":"try { _ = ctx.Model; } catch (InvalidOperationException ex) when (ex.Message.Contains(\"another parameter with this name already exists\")) { /* rename or remove the duplicate parameter */ }","preventionTips":["When binding both current and original values of one property, give the original-value param a distinct store name."],"tags":["ef-core","stored-procedures","parameters","duplicate","model-validation"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}