dotnet/efcore · error · InvalidOperationException
The result column for the property
Error message
The result column for the property '{property}' cannot be added to the stored procedure '{sproc}' because another result column for this property already exists. What it means
A stored procedure cannot project the same property into two result columns. AddResultColumn(propertyName) throws when _propertyResultColumns already contains that property name, since each mapped property may contribute at most one output column.
Solutions
- Call FindResultColumn(propertyName) before adding; only add when it returns null.
- Remove the duplicate .ResultColumn(propertyName) call.
- If the property is store-generated, let conventions create the result column and do not add it manually.
- Audit each procedure's GetResultColumns() to confirm no duplicates before fluent configuration.
Example fix
// before
sp.ResultColumn("RowVersion");
sp.ResultColumn("RowVersion"); // throws: duplicate
// after
if (sp.FindResultColumn("RowVersion") is null)
{
sp.ResultColumn("RowVersion");
} Defensive patterns
Strategy: validation
Validate before calling
// Add a result column only if no column exists for that property.
if (sp.FindResultColumn(propertyName) is null)
{
sp.ResultColumn(propertyName);
} Type guard
static bool CanAddResultColumn(IStoredProcedure sp, string propertyName)
=> sp.FindResultColumn(propertyName) is null; Prevention
- Build a small wrapper that checks FindResultColumn before adding.
- Avoid manually adding result columns for store-generated properties that conventions already map.
- Unit-test procedure configurations against the finalized model.
When it happens
Trigger: Calling .ResultColumn("CreatedAt") twice on the same procedure, or calling it once explicitly when convention/attribute mapping already added a result column for that property (e.g. a computed property auto-mapped as a result column).
Common situations: Adding explicit result columns on top of auto-discovered ones after an EF Core upgrade changed convention behavior; shared fluent code between insert and update procedures where the same property is re-listed; mapping a store-generated (computed/default) property that conventions already treat as a result column.
Related errors
- The rows affected parameter cannot be added to the stored…
- The rows affected result column cannot be added to the…
- ' ' cannot be configured for the parameter ' ' of the…
- The entity type ' ' was not found. Ensure that the entity…
- Unsupported direction
AI-assisted analysis of dotnet/efcore@3a2006ef56 (2026-08-11).
Data as JSON: /api/errors/7248799d9e3d3778.
Report an issue: GitHub.
Appendix: source
Thrown at src/EFCore.Relational/Metadata/Internal/StoredProcedure.cs:620
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual StoredProcedureResultColumn? FindResultColumn(string propertyName)
=> _propertyResultColumns.GetValueOrDefault(propertyName);
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual StoredProcedureResultColumn AddResultColumn(string propertyName)
{
if (_propertyResultColumns.ContainsKey(propertyName))
{
throw new InvalidOperationException(
RelationalStrings.StoredProcedureDuplicateResultColumn(
propertyName, ((IReadOnlyStoredProcedure)this).GetStoreIdentifier()?.DisplayName()));
}
var resultColumn = new StoredProcedureResultColumn(this, forRowsAffected: false, propertyName);
_resultColumns.Add(resultColumn);
_propertyResultColumns.Add(propertyName, resultColumn);
return resultColumn;
}
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual StoredProcedureResultColumn? FindRowsAffectedResultColumn()View on GitHub (pinned to 3a2006ef56)