{"record":{"id":"bb81bde4cc6901cb","repo":"dotnet/efcore","slug":"there-is-no-entity-type-mapped-to-the-table-tabl","errorCode":null,"errorMessage":"There is no entity type mapped to the table '{table}' which is used in a data operation. Either add the corresponding entity type to the model, or specify the column types in the data operation.","messagePattern":"There is no entity type mapped to the table '(.+?)' which is used in a data operation\\. Either add the corresponding entity type to the model, or specify the column types in the data operation\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Migrations/MigrationsSqlGenerator.cs","lineNumber":1170,"sourceCode":"            }\n\n            yield return modificationCommand;\n        }\n    }\n\n    private static string FormatTable(string table, string? schema)\n        => schema == null ? table : schema + \".\" + table;\n\n    private static IColumnMapping[] GetPropertyMappings(\n        string[] names,\n        string tableName,\n        string? schema,\n        IModel? model)\n    {\n        var table = model?.GetRelationalModel().FindTable(tableName, schema ?? model.GetDefaultSchema());\n        if (table == null)\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.DataOperationNoTable(\n                    FormatTable(tableName, schema)));\n        }\n\n        var properties = new IColumnMapping[names.Length];\n        for (var i = 0; i < names.Length; i++)\n        {\n            var name = names[i];\n            var column = table.FindColumn(name);\n            if (column == null)\n            {\n                throw new InvalidOperationException(\n                    RelationalStrings.DataOperationNoProperty(\n                        FormatTable(tableName, schema), name));\n            }\n\n            properties[i] = column.PropertyMappings.First();\n        }","sourceCodeStart":1152,"sourceCodeEnd":1188,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Migrations/MigrationsSqlGenerator.cs#L1152-L1188","documentation":"Thrown by GetPropertyMappings when a data operation references a table that does not exist in the relational model. EF needs the table to look up column metadata for type resolution.","triggerScenarios":"DeleteData/UpdateData referencing a table name that model.GetRelationalModel().FindTable(...) cannot resolve. Only fires when explicit types are NOT supplied, so the model must be consulted.","commonSituations":"Typos in table name. Data operation placed in a migration before the CreateTable that introduces the table. Split migrations where the table lives in a different migration. Schema mismatch (custom schema vs default).","solutions":["Correct the table name (and schema) in the data operation to match the entity's ToTable mapping.","Move the DeleteData/UpdateData call after the CreateTable/AddColumn that defines the table in this migration.","Supply keyColumnTypes/columnTypes explicitly so GetPropertyMappings is bypassed.","Re-scaffold the migration to capture the correct table reference."],"exampleFix":"// before\nmigrationBuilder.DeleteData(\n    table: \"Usrs\", // typo\n    keyColumns: new[] { \"Id\" },\n    keyValues: new object[,] { { 10 } });\n\n// after\nmigrationBuilder.DeleteData(\n    table: \"Users\",\n    keyColumns: new[] { \"Id\" },\n    keyValues: new object[,] { { 10 } });","handlingStrategy":"validation","validationCode":"static void VerifyTableExists(IModel model, string table, string? schema)\n{\n    var t = model.GetRelationalModel().FindTable(table, schema ?? model.GetDefaultSchema());\n    if (t is null)\n        throw new InvalidOperationException($\"Table {schema}.{table} not present in the relational model.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Reference table names exactly as mapped by ToTable.","Order migration operations so CreateTable precedes DeleteData/UpdateData.","Pass explicit column types to bypass model table lookup when in doubt."],"tags":["ef-core","migrations","data-seed","model-binding"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}