You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class Example
{
public int Id { get; set; }
[Timestamp]
[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
[Column("xmin", TypeName = "xid")]
public uint RowVersion { get; set; }
}
I want to delete from that record by ID without having to load it. Using this:
var example = new Example{ Id = 1 };
context.Entry(example).State = EntityState.Deleted;
await context.SaveChangesAsync();
What happens:
We get a concurrency exception, as the query tries to delete where ID = xx and xmin = yy. The xmin isn't the same, so it doesn't work.
What I expected to happen:
It to delete the record.
Or am I making false assumptions here?
The text was updated successfully, but these errors were encountered:
This behavior is by design; if you're configuring a concurrency token, then you must have the most up-to-date value of that concurrency token in the entity instance when making updates or deleting; this isn't related to PostgreSQL xmin specifically, you should be able to see it with other types of concurrency tokens.
dotnet/efcore#10443 tracks opting out of optimistic concurrency for a specific operation - this could help here. But until that's done, you'll have to load the entity from the database to get the actual xmin value.
Hi,
I have the following table:
I want to delete from that record by ID without having to load it. Using this:
What happens:
We get a concurrency exception, as the query tries to delete where ID = xx and xmin = yy. The xmin isn't the same, so it doesn't work.
What I expected to happen:
It to delete the record.
Or am I making false assumptions here?
The text was updated successfully, but these errors were encountered: