I have a .NET Core 2.2 api using a Postgres database via the Npgsql Entity Framework provider. I've defined a column as an identity column (OrderNumber) using UseNpgsqlIdentityAlwaysColumn() on the model builder. This all works fine until I try and update an entity. At this point I get the exception:
- InnerException {Npgsql.PostgresException (0x80004005): 428C9: column "OrderNumber" can only be updated to DEFAULT
The value of the OrderNumber column wasn't changed. Is there a way to tell Npgsql not to try and update that column?
My entity property is defined as:
/// <summary>
/// Unique order number generated by the system for this request
/// </summary>
public int OrderNumber { get; set; }
The model builder definition is:
// Additional auto-increment columns
builder.Entity<DeliveryRequest>().Property(e => e.OrderNumber).UseNpgsqlIdentityAlwaysColumn();
If it helps, I'm using Npgsql.EntityFrameworkCore.PostgreSQL 2.2.4
User contributions licensed under CC BY-SA 3.0