{"record":{"id":"dc4b160bf1ed2af9","repo":"dotnet/efcore","slug":"the-data-modification-operation-on-table-is-no","errorCode":null,"errorMessage":"The data modification operation on '{table}' is not associated with a model. Either add a model to the migration, or specify the column types in all data operations.","messagePattern":"The data modification operation on '(.+?)' is not associated with a model\\. Either add a model to the migration, or specify the column types in all data operations\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Migrations/MigrationsSqlGenerator.cs","lineNumber":1098,"sourceCode":"            && operation.KeyColumns.Length != operation.KeyColumnTypes.Length)\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.UpdateDataOperationKeyTypesCountMismatch(\n                    operation.KeyColumnTypes.Length, operation.KeyColumns.Length, FormatTable(operation.Table, operation.Schema)));\n        }\n\n        if (operation.ColumnTypes != null\n            && operation.Columns.Length != operation.ColumnTypes.Length)\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.UpdateDataOperationTypesCountMismatch(\n                    operation.ColumnTypes.Length, operation.Columns.Length, FormatTable(operation.Table, operation.Schema)));\n        }\n\n        if (operation.KeyColumnTypes == null\n            && model == null)\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.UpdateDataOperationNoModel(\n                    FormatTable(operation.Table, operation.Schema)));\n        }\n\n        var keyPropertyMappings = operation.KeyColumnTypes == null\n            ? GetPropertyMappings(operation.KeyColumns, operation.Table, operation.Schema, model)\n            : null;\n        var propertyMappings = operation.ColumnTypes == null\n            ? GetPropertyMappings(operation.Columns, operation.Table, operation.Schema, model)\n            : null;\n\n        for (var i = 0; i < operation.KeyValues.GetLength(0); i++)\n        {\n            var modificationCommand = Dependencies.ModificationCommandFactory.CreateNonTrackedModificationCommand(\n                new NonTrackedModificationCommandParameters(operation.Table, operation.Schema, SensitiveLoggingEnabled));\n            modificationCommand.EntityState = EntityState.Modified;\n\n            for (var j = 0; j < operation.KeyColumns.Length; j++)","sourceCodeStart":1080,"sourceCodeEnd":1116,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Migrations/MigrationsSqlGenerator.cs#L1080-L1116","documentation":"Thrown for an UpdateData operation when neither KeyColumnTypes nor a model is available. EF cannot resolve store types for key/value parameters without at least one of them. Update also requires ColumnTypes-or-model for the value columns, but this specific guard fires on the key side first.","triggerScenarios":"migrationBuilder.UpdateData(...) with no keyColumnTypes, executed in a pipeline that does not pass a target model. Triggered when operation.KeyColumnTypes == null && model == null.","commonSituations":"Manual use of MigrationBuilder outside the Migrator. Design-time operations on a migrations-only assembly with no DbContext. Stripping BuildTargetModel from a generated migration.","solutions":["Pass keyColumnTypes (and columnTypes) for every column referenced so EF can resolve mappings without a model.","Run the migration through the standard Migrator which supplies the model.","Re-scaffold the migration via dotnet ef migrations add so BuildTargetModel is emitted."],"exampleFix":"// before\nmigrationBuilder.UpdateData(\n    table: \"Users\",\n    keyColumns: new[] { \"Id\" },\n    keyValues: new object[,] { { 10 } },\n    columns: new[] { \"Name\" },\n    values: new object[,] { { \"Ann\" } });\n\n// after\nmigrationBuilder.UpdateData(\n    table: \"Users\",\n    keyColumns: new[] { \"Id\" },\n    keyColumnTypes: new[] { \"int\" },\n    keyValues: new object[,] { { 10 } },\n    columns: new[] { \"Name\" },\n    columnTypes: new[] { \"nvarchar(max)\" },\n    values: new object[,] { { \"Ann\" } });","handlingStrategy":"validation","validationCode":"static void EnsureUpdateDataResolvable(string[]? keyColumnTypes, string[]? columnTypes, IModel? model, string table)\n{\n    if (model is null && (keyColumnTypes is null || columnTypes is null))\n        throw new InvalidOperationException($\"{table}: UpdateData needs a model, or both keyColumnTypes and columnTypes.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always scaffold migrations so they carry BuildTargetModel.","When running standalone, supply both keyColumnTypes and columnTypes.","Avoid deleting BuildTargetModel from generated migrations."],"tags":["ef-core","migrations","updatedata","model-binding"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}