dotnet/efcore · error · InvalidOperationException

There is no property mapped to the column

Error message

There is no property mapped to the column '{table}.{column}' which is used in a data operation. Either add a property mapped to this column, or specify the column types in the data operation.

What it means

Thrown by GetPropertyMappings when the table exists in the relational model but no column with the given name is mapped. EF walks each column name through table.FindColumn(name) and aborts on the first miss.

Solutions

  1. Correct the column name to match the mapped property's column name.
  2. Add the property/column mapping to the entity if it should exist.
  3. Supply keyColumnTypes/columnTypes to bypass model column lookup.
  4. Re-scaffold the migration to use the correct column names.

Example fix

// before
migrationBuilder.DeleteData(
    table: "Users",
    keyColumns: new[] { "UserId" }, // column is actually "Id"
    keyValues: new object[,] { { 10 } });

// after
migrationBuilder.DeleteData(
    table: "Users",
    keyColumns: new[] { "Id" },
    keyValues: new object[,] { { 10 } });
Defensive patterns

Strategy: validation

Validate before calling

static void VerifyColumnsExist(IModel model, string table, string? schema, IEnumerable<string> columns)
{
    var t = model.GetRelationalModel().FindTable(table, schema ?? model.GetDefaultSchema())
        ?? throw new InvalidOperationException($"Table {table} missing.");
    foreach (var c in columns)
        if (t.FindColumn(c) is null)
            throw new InvalidOperationException($"Column {table}.{c} not mapped.");
}

Prevention

When it happens

Trigger: DeleteData/UpdateData with a keyColumns/columns entry that does not match any column on the resolved table. Only fires when explicit types are not supplied.

Common situations: Column renamed in entity but migration hand-edited with the old name. Misspelled column name. Composite key with a column not actually mapped. Schema drift between model and migration.

Related errors


AI-assisted analysis of dotnet/efcore@3a2006ef56 (2026-08-11). Data as JSON: /api/errors/ca5bd8723754c1ff. Report an issue: GitHub.

Appendix: source

Thrown at src/EFCore.Relational/Migrations/MigrationsSqlGenerator.cs:1182

        string? schema,
        IModel? model)
    {
        var table = model?.GetRelationalModel().FindTable(tableName, schema ?? model.GetDefaultSchema());
        if (table == null)
        {
            throw new InvalidOperationException(
                RelationalStrings.DataOperationNoTable(
                    FormatTable(tableName, schema)));
        }

        var properties = new IColumnMapping[names.Length];
        for (var i = 0; i < names.Length; i++)
        {
            var name = names[i];
            var column = table.FindColumn(name);
            if (column == null)
            {
                throw new InvalidOperationException(
                    RelationalStrings.DataOperationNoProperty(
                        FormatTable(tableName, schema), name));
            }

            properties[i] = column.PropertyMappings.First();
        }

        return properties;
    }

    /// <summary>
    ///     Generates a SQL fragment configuring a sequence in a <see cref="AlterSequenceOperation" />.
    /// </summary>
    /// <param name="operation">The operation.</param>
    /// <param name="model">The target model which may be <see langword="null" /> if the operations exist without a model.</param>
    /// <param name="builder">The command builder to use to add the SQL fragment.</param>
    protected virtual void SequenceOptions(
        AlterSequenceOperation operation,

View on GitHub (pinned to 3a2006ef56)