Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Blog - Optimistic concurrency with MySQL and Entity Framework
Property(x => x.Version).IsRequired()
.IsConcurrencyToken()
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed);
var concurrencyTokenEntries = ChangeTracker.Entries<IVersionedEntity>();
foreach (var entry in concurrencyTokenEntries)
{
if (entry.State == EntityState.Unchanged)
{
continue;
}
entry.Entity.Version = Guid.NewGuid();
}
TIMESTAMP type with default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
Property(x => x.Version).IsRequired()
.IsConcurrencyToken()
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
public System.Guid Version { get; set; }
public interface IVersionedEntity
{
Guid Version { get; set; }
}
@sverrehundeide

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.