Understanding the Error
The ObjectDisposedException typically occurs when an attempt is made to use an object that has already been disposed. In the context of ASP.NET Core and Entity Framework, this often involves the DbContext. The error message generally looks like this:
Continue reading “Cannot access a disposed object in ASP.NET Core when injecting DbContext”System.ObjectDisposedException: Cannot access a disposed object.
In a scenario where we were using SQL server as a queue, before publishing events to external queues, we wanted the data to be processed only once and in order, even with multiple processors for failover. When reading from the table we wanted to lock the records and block other processors from reading those records, while being processed. This is called Pessimistic Concurrency, unfortunately Entity Framework Core does not support this out of the box. To realize Pessimistic Concurrency you need to write your own SQL queries directly on the database (The solution is database type bound, in this case Microsoft SQL server). This blog post will show how it can be accomplished.
From an deployment perspective an Azure Function contains of two parts: