{"repo":"mnbuhl/efcore-locking","free":true,"listed":false,"github":"https://github.com/mnbuhl/efcore-locking","clone":"git clone https://github.com/mnbuhl/efcore-locking.git","description":"Pessimistic row-level locking and distributed advisory locks for EF Core — ForUpdate() / ForShare()","language":"C#","stars":59,"topics":["csharp","distributed-lock","dotnet","efcore","entity-framework-core","mysql","pessimistic-locking","postgresql","sqlserver"],"license":"MIT","category":"databases-storage","readme_excerpt":"EntityFrameworkCore.Locking Pessimistic locking for EF Core. Supports PostgreSQL, MySQL, and SQL Server. - Row-level locks — ForUpdate() / ForShare() LINQ extensions, scoped to a transaction - Distributed locks — AcquireDistributedLockAsync() session-scoped advisory locks, no transaction required Installation Setup Call .UseLocking() after your provider's Use () call: Row-level locks All row-level locking queries require an active transaction . PostgreSQL-only modes Available when referencing EntityFrameworkCore.Locking.PostgreSQL : Include with locking On PostgreSQL, collection Include emits FOR UPDATE OF \"t\" automatically to handle the outer join, so you can use Include directly without AsSplitQuery() : Queue processing ForUpdate(LockBehavior.SkipLocked) is the standard building block for a worker queue where multiple consumers race to claim items: Lock modes and behaviors Method Generated SQL -------- -------------- ForUpdate() FOR UPDATE / WITH (UPDLOCK, HOLDLOCK, ROWLOCK) ForUpdate(LockBehavior.NoWait) FOR UPDATE NOWAIT / SET LOCK TIMEOUT 0 ForUpdate(LockBehavior.SkipLocked) FOR UPDATE SKIP LOCKED (PG/MySQL) / WITH (UPDLOCK, ROWLOCK, READPAST) (SQL Server) ForUpdate(LockBehavior.Wait, timeout) SET LOCAL lock timeout (PG) / SET SESSION innodb lock wait timeout (MySQL) / SET LOCK TIMEOUT (SQL Server) ForShare() FOR SHARE (PostgreSQL/MySQL only) ForNoKeyUpdate() FOR NO KEY UPDATE (PostgreSQL only) ForKeyShare() FOR KEY SHARE (PostgreSQL only) Distributed locks Advisory lock","default_branch":null,"files":null,"tree":[],"storefront":"/r/mnbuhl","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/mnbuhl/efcore-locking/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}