Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid column name 'Nickname'. means EF Core asked SQL Server for a column the table does not have. The entity class gained a property, the database did not gain the column, because no migration was added and applied for it.

Run dotnet ef migrations add with a name for the change, then dotnet ef database update. The next query works, and because the new property is nullable the existing rows simply get NULL in the new column.

The error

fail: 23-10-2026 10:10:16.939 RelationalEventId.CommandError[20102] (Microsoft.EntityFrameworkCore.Database.Command)
      Failed executing DbCommand (11ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
      SELECT [c].[Id], [c].[Name], [c].[Nickname]
      FROM [Customers] AS [c]
      ORDER BY [c].[Id]
Unhandled exception. Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid column name 'Nickname'.

The SQL above the exception comes from LogTo on the context; without it you see only the exception. The stack trace ends with Error Number:207,State:1,Class:16, SQL Server's number for an unknown column.

Why it happens

EF Core writes SQL from its model, the entity classes plus their configuration, and never looks at the real table to see what it has. The database was built by a first migration with Id and Name; then public string? Nickname { get; set; } was added to Customer and the app was run again. Every query for customers now selects Nickname, even this one, whose code only printed the id and the name, and SQL Server refuses the whole statement before it reads a row.

The model and the schema are kept in step only by migrations. A new property without a migration compiles, starts and fails at the first query that touches the entity.

The fix

dotnet ef migrations add AddNickname
dotnet ef database update

The migration EF Core scaffolded, and the statement the update ran:

migrationBuilder.AddColumn<string>(
    name: "Nickname",
    table: "Customers",
    type: "nvarchar(max)",
    nullable: true);
Applying migration '20261023044052_AddNickname'.
      ALTER TABLE [Customers] ADD [Nickname] nvarchar(max) NULL;

The same query afterwards:

      SELECT [c].[Id], [c].[Name], [c].[Nickname]
      FROM [Customers] AS [c]
      ORDER BY [c].[Id]
1 Maria Garcia
2 David Chen

Two guards catch the mistake before a query does. dotnet ef migrations has-pending-model-changes printed Changes have been made to the model since the last migration. Add a new migration. and exited with code 1, which fails a CI step on its own. And Database.Migrate() or dotnet ef database update without the new migration threw the "model for context 'AppDb' has pending changes" exception, raised from the PendingModelChangesWarning; the pending changes post covers that one.

The same 207 has a second classic cause: the app and dotnet ef use two connection strings that point at two databases. A second database migrated only to the first migration gave the identical error here, while the updated one worked; compare the server and database names in both.

How it was reproduced

A console project on .NET SDK 10.0.402 with Microsoft.EntityFrameworkCore.SqlServer 10.0.13 and Microsoft.EntityFrameworkCore.Design 10.0.13, the dotnet-ef global tool 10.0.0 (which warns that it is older than the 10.0.13 runtime, harmless here), and SQL Server 2022 LocalDB 16.0.1210.3 on Windows 11. Customer, AppDb, Nickname and the two databases are the test's own, and both databases were dropped afterwards.

Frequently asked

Why does EF Core say Invalid column name after I added a property?
EF Core builds its SQL from the entity classes, so the new property is selected in every query, but the table only gets the column when a migration adds it. Add a migration with dotnet ef migrations add and apply it with dotnet ef database update.
Do I need a new migration for every new property in EF Core?
Yes, for every change that alters the schema, and a new mapped property always does. If you are not sure whether a change needs one, run dotnet ef migrations has-pending-model-changes: it says whether the model differs from the last migration.
How do I check for a missing EF Core migration in CI?
Run dotnet ef migrations has-pending-model-changes. It prints that changes have been made since the last migration and exits with code 1 when the model and the last migration differ, and exits with 0 when they match.

To check which database a connection string really names, paste it into the connection string checker; every dotnet ef command used here is in the dotnet ef reference. More decoded errors in the Fixes category.