dotnet/efcore · error · InvalidOperationException
The property '{entityType}.{property}' is mapped to a result
Error message
The property '{entityType}.{property}' is mapped to a result column of the stored procedure '{sproc}', but it is not configured as store-generated. What it means
Thrown when a property mapped to a result column is not configured as store-generated. Result columns carry values the database produces, so the property must be marked ValueGenerated.OnAdd (for insert) or OnUpdate (for update). The validator rejects the property if it is absent from the storeGeneratedProperties set.
Source
Thrown at src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs:682
if (!resultColumnNames.Add(resultColumn.Name))
{
throw new InvalidOperationException(
RelationalStrings.StoredProcedureDuplicateResultColumnName(
resultColumn.Name, storeObjectIdentifier.DisplayName()));
}
if (resultColumn.PropertyName == null)
{
continue;
}
switch (storeObjectIdentifier.StoreObjectType)
{
case StoreObjectType.InsertStoredProcedure:
case StoreObjectType.UpdateStoredProcedure:
if (!storeGeneratedProperties.ContainsKey(property.Name))
{
throw new InvalidOperationException(
RelationalStrings.StoredProcedureResultColumnNotGenerated(
entityType.DisplayName(), resultColumn.PropertyName, storeObjectIdentifier.DisplayName()));
}
break;
case StoreObjectType.DeleteStoredProcedure:
throw new InvalidOperationException(
RelationalStrings.StoredProcedureResultColumnDelete(
entityType.DisplayName(), resultColumn.PropertyName, storeObjectIdentifier.DisplayName()));
default:
Check.DebugFail("Unexpected stored procedure type: " + storeObjectIdentifier.StoreObjectType);
break;
}
}
var originalValueProperties = new Dictionary<string, IProperty>(properties);
var parameterNames = new HashSet<string>();
foreach (var parameter in sproc.Parameters)View on GitHub (pinned to dbf9771522)
Solutions
- Mark the property store-generated: .ValueGenerated(ValueGenerated.OnAdd) (insert) or .ValueGenerated.OnUpdate (update).
- Or annotate it as a computed column via HasComputedColumnSql.
- Remove the result column if the property is not actually store-generated.
Example fix
// before
sp.HasResultColumn("Id"); // Id not configured as generated
// after
modelBuilder.Entity<Blog>().Property(b => b.Id).ValueGeneratedOnAdd();
sp.HasResultColumn("Id"); Defensive patterns
Strategy: validation
Validate before calling
foreach (var et in modelBuilder.Model.GetEntityTypes())
{
foreach (var kv in new[] { (StoreObjectType.InsertStoredProcedure, et.GetInsertStoredProcedure()), (StoreObjectType.UpdateStoredProcedure, et.GetUpdateStoredProcedure()) })
{
var (t, s) = kv; if (s == null) continue;
foreach (var rc in s.ResultColumns.Where(r => r.PropertyName != null))
{
var p = et.FindProperty(rc.PropertyName);
var needed = t == StoreObjectType.InsertStoredProcedure ? ValueGenerated.OnAdd : ValueGenerated.OnUpdate;
if (p != null && (p.ValueGenerated & needed) == 0)
throw new InvalidOperationException($"{rc.PropertyName} must be store-generated");
}
}
} Try / catch
try { _ = ctx.Model; } catch (InvalidOperationException ex) when (ex.Message.Contains("not configured as store-generated")) { /* mark the property ValueGenerated or remove the result column */ } Prevention
- Only map result columns to properties marked ValueGenerated.OnAdd/OnUpdate.
- Use result columns exclusively for identity, computed, and timestamp columns.
When it happens
Trigger: .HasResultColumn("Id") on an insert sproc without .ValueGenerated(ValueGenerated.OnAdd) on the Id property; mapping a regular column to a result column.
Common situations: Forgetting to mark an identity/computed column as ValueGenerated; treating a client-set property as store output.
Related errors
- No property named '{property}' found on the entity type '{en
- The result column '{column}' cannot be added to the stored p
- The property '{entityType}.{property}' is mapped to a result
- The property '{entityType}.{property}' is mapped to an outpu
- The entity type '{entityType}' is mapped to the stored proce
AI-assisted analysis of dotnet/efcore@dbf9771522 (2026-08-06).
Data as JSON: /api/errors/d0f9904921ca1d97.
Report an issue: GitHub.