{"record":{"id":"5083d7f7aebdae41","repo":"dotnet/efcore","slug":"executeupdate-or-executedelete-was-called-on-e-5083d7","errorCode":null,"errorMessage":"'ExecuteUpdate' or 'ExecuteDelete' was called on entity type '{entityType}', but that entity type is not mapped to a table.","messagePattern":"'ExecuteUpdate' or 'ExecuteDelete' was called on entity type '(.+?)', but that entity type is not mapped to a table\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.ExecuteUpdate.cs","lineNumber":485,"sourceCode":"                            // See #28520 about improving this.\n                            var containerColumnName = complexType.GetContainerColumnName();\n                            if (containerColumnName != null)\n                            {\n                                targetColumnModel = complexType.GetTableMappings()\n                                    .Select(m => m.Table.FindColumn(containerColumnName))\n                                    .SingleOrDefault(c => c is not null);\n                            }\n\n                            break;\n                        }\n\n                        default:\n                            throw new UnreachableException();\n                    }\n\n                    if (targetColumnModel is null)\n                    {\n                        throw new InvalidOperationException(\n                            RelationalStrings.ExecuteUpdateDeleteOnEntityNotMappedToTable(targetProperty.DeclaringType.DisplayName()));\n                    }\n\n                    unwrappedTableExpression = new TableExpression(unwrappedTableExpression.Alias, targetColumnModel.Table);\n                    tableExpression = tableExpression is JoinExpressionBase join\n                        ? join.Update(unwrappedTableExpression)\n                        : unwrappedTableExpression;\n                    var newTables = select.Tables.ToList();\n                    newTables[tableIndex] = tableExpression;\n\n                    // Note that we need to keep the select mutable, because if IsValidSelectExpressionForExecuteDelete below\n                    // returns false, we need to compose on top of it.\n                    select.SetTables(newTables);\n                }\n\n                CheckColumnOnSameTable(column, propertySelector);\n            }\n","sourceCodeStart":467,"sourceCodeEnd":503,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.ExecuteUpdate.cs#L467-L503","documentation":"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.","triggerScenarios":"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.","commonSituations":"Entities mapped to views (ToView), query defs, HasNoKey types, or split entities where the targeted property lives on a fragment without a writable table.","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."],"exampleFix":"// before\nmodelBuilder.Entity<CustomerReport>().ToView(\"CustomerReports\");\nawait ctx.Set<CustomerReport>().ExecuteUpdateAsync(s => s.SetProperty(c => c.Note, \"x\"));\n// after\nmodelBuilder.Entity<Customer>().ToTable(\"Customers\");\nawait ctx.Set<Customer>().ExecuteUpdateAsync(s => s.SetProperty(c => c.Note, \"x\"));","handlingStrategy":"validation","validationCode":"// Verify the entity type is mapped to a table before ExecuteUpdate/ExecuteDelete.\nIEntityType? et = ctx.Model.FindEntityType(typeof(T));\nif (et?.GetTableName() is null)\n    throw new InvalidOperationException($\"{et?.Name} is not mapped to a table.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["efcore","executeupdate","executedelete","table-mapping","query-translation"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}