dotnet/efcore · error · InvalidOperationException
'ExecuteUpdate' or 'ExecuteDelete' was called on entity type
Error message
'ExecuteUpdate' or 'ExecuteDelete' was called on entity type '{entityType}', but that entity type is not mapped to a table. What it means
Thrown when ExecuteUpdate (or ExecuteDelete) cannot resolve a target table for the property being set. After drilling through table expressions (joins, etc.) the translator found targetColumnModel null, meaning the declaring type of the target property is not mapped to a table — e.g. a keyless type, a query type, or a complex/owned type without table mapping.
Source
Thrown at src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.ExecuteUpdate.cs:485
// See #28520 about improving this.
var containerColumnName = complexType.GetContainerColumnName();
if (containerColumnName != null)
{
targetColumnModel = complexType.GetTableMappings()
.Select(m => m.Table.FindColumn(containerColumnName))
.SingleOrDefault(c => c is not null);
}
break;
}
default:
throw new UnreachableException();
}
if (targetColumnModel is null)
{
throw new InvalidOperationException(
RelationalStrings.ExecuteUpdateDeleteOnEntityNotMappedToTable(targetProperty.DeclaringType.DisplayName()));
}
unwrappedTableExpression = new TableExpression(unwrappedTableExpression.Alias, targetColumnModel.Table);
tableExpression = tableExpression is JoinExpressionBase join
? join.Update(unwrappedTableExpression)
: unwrappedTableExpression;
var newTables = select.Tables.ToList();
newTables[tableIndex] = tableExpression;
// Note that we need to keep the select mutable, because if IsValidSelectExpressionForExecuteDelete below
// returns false, we need to compose on top of it.
select.SetTables(newTables);
}
CheckColumnOnSameTable(column, propertySelector);
}
View on GitHub (pinned to 3a2006ef56)
Solutions
- Ensure the entity type is mapped to a table (ToTable) and is not view-only or keyless.
- If split across tables, target only properties whose declaring type maps to a writable table.
- For view-mapped types, perform updates through a keyed, table-mapped entity instead.
Example fix
// before
modelBuilder.Entity<CustomerReport>().ToView("CustomerReports");
await ctx.Set<CustomerReport>().ExecuteUpdateAsync(s => s.SetProperty(c => c.Note, "x"));
// after
modelBuilder.Entity<Customer>().ToTable("Customers");
await ctx.Set<Customer>().ExecuteUpdateAsync(s => s.SetProperty(c => c.Note, "x")); Defensive patterns
Strategy: validation
Validate before calling
// Verify the entity type is mapped to a table before ExecuteUpdate/ExecuteDelete.
IEntityType? et = ctx.Model.FindEntityType(typeof(T));
if (et?.GetTableName() is null)
throw new InvalidOperationException($"{et?.Name} is not mapped to a table."); Prevention
- Map entities used for bulk write to a real table (ToTable), not ToView.
- Keep keyless or view-mapped types read-only.
- Add a startup check that write-target entities have a table mapping.
When it happens
Trigger: Calling ExecuteUpdate where the property's declaring type has no table mapping (mapped to a view, TVF, or nothing), or where the setter targets a property of a type that the table-resolution walk cannot anchor. The sibling ExecuteDelete path throws the same message.
Common situations: Entities mapped to views (ToView), query defs, HasNoKey types, or split entities where the targeted property lives on a fragment without a writable table.
Related errors
- The operation '{operation}' cannot be performed on keyless e
- The operation 'ExecuteDelete' requires an entity type which
- 'ExecuteUpdate' or 'ExecuteDelete' was called on entity type
- The operation '{operation}' cannot be performed on keyless e
- The following lambda argument to 'SetProperty' does not repr
AI-assisted analysis of dotnet/efcore@3a2006ef56 (2026-08-11).
Data as JSON: /api/errors/5083d7f7aebdae41.
Report an issue: GitHub.