BUG: Migration tries to create xmin system column
ISSUE
When configuring optimistic concurrency by mapping a uint property to PostgreSQL’s xmin/xid, the migration generator incorrectly emits an AddColumn for xmin.
Applying the migration fails with:
column "xmin" conflicts with a system column name
Attempting to work around this by removing the generated defaultValue: 0u does not resolve the issue. Instead, EF Core then fails with:
23502: column "<column_name>" contains null values
This creates a deadlock:
- Keeping the default → conflicts with system column (
xmin)
- Removing the default → violates NOT NULL constraint on existing rows
In environments where generated migrations cannot be modified manually, this blocks deployment entirely.
Repro
- Entity:
public class Account
{
public int account_id { get; set; }
public uint Version { get; set; }
}
- Config:
builder.Property(a => a.Version).IsRowVersion()
.HasColumnName("xmin")
.HasColumnType("xid")
.ValueGeneratedOnAddOrUpdate()
.IsConcurrencyToken();
- Run:
dotnet ef migrations add AddConcurrency
- Generated migration includes:
migrationBuilder.AddColumn<uint>(
name: "xmin",
table: "Accounts",
type: "xid",rowVersion: true,
nullable: false,
defaultValue: 0u);
- Removing
defaultValue results in:
23502: column "<column_name>" contains null values
- Applying migration fails in all cases
EXPECTED
The provider should recognize mappings to PostgreSQL system columns (xmin/xid) and suppress any physical DDL (e.g., AddColumn) for them.
ENVIRONMENT
- PostgreSQL: PostgreSQL16
- Npgsql.EntityFrameworkCore.PostgreSQL: 10.0.1
- .NET: 10.0.201
BUG: Migration tries to create
xminsystem columnISSUE
When configuring optimistic concurrency by mapping a
uintproperty to PostgreSQL’sxmin/xid, the migration generator incorrectly emits anAddColumnforxmin.Applying the migration fails with:
column "xmin" conflicts with a system column nameAttempting to work around this by removing the generated
defaultValue: 0udoes not resolve the issue. Instead, EF Core then fails with:23502: column "<column_name>" contains null valuesThis creates a deadlock:
xmin)In environments where generated migrations cannot be modified manually, this blocks deployment entirely.
Repro
defaultValueresults in:EXPECTED
The provider should recognize mappings to PostgreSQL system columns (
xmin/xid) and suppress any physical DDL (e.g.,AddColumn) for them.ENVIRONMENT