postgresqlentity-frameworkoptimistic-concurrencyrowversion

RowVersion implementation on Entity Framework for PostgreSQL


I am using Entity Framework 6 with PostgreSQL. I have an entity in which I want to prevent concurrency issues, following this documentation I added a RowVersion property with [Timestamp] attribute, however after saving changes to the entity the column RowVersion value stays the same in the database.

    [Timestamp]
    public byte[] RowVersion { get; set; }

Am I missing something or is there another way to handle it in PostgreSQL?


Solution

  • /// <summary>
    /// Meant to validate concurrency en database update
    /// This column is updates itself in database and only works in postgresql
    /// </summary>
    [ConcurrencyCheck]
    [DatabaseGenerated(DatabaseGeneratedOption.Computed)]
    //[NotMapped]
    public string xmin { get; set; }
    

    Had to add [NotMapped] attribute just for the column not to be added in the migration, commented it after database-update.