In T-SQL, to resolve the insert/update racing condition, one uses WITH (UPDLOCK, SERIALIZABLE)
. Example: two session threads trying to insert on the same primary key:
- Mythbusting Concurrent Update Insert Connections, Michael Swart
- Insert Update Racing Condition, Dan Guzman
Example:
IF EXISTS(SELECT *
FROM dbo.Foo WITH (UPDLOCK, HOLDLOCK)
WHERE ID = @ID)
How does one apply this in the latest version of C# ASP Entity Framework 6 EF6 for the OLTP environment? What are the keywords to utilize in EF6?
Instead of using Inline SQL above, I would rather refer to the C# class objects.
Thanks,