Implement Pessimistic Concurrency in Entity Framework Core

ConcurrencyIn 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.
Continue reading “Implement Pessimistic Concurrency in Entity Framework Core”

Advertisements

Entity Framework and Full Text Search

Out of the box Entity Framework does not support Full Text Search. To do Full Text Search you have a number of options to get it working. In this blog post I’ll describe a method to get Full Text Search working using a table valued function. The method does the Full Text Search in a table valued function that returns an id list, the returned ids can be used to filter the records from an actual table.
Continue reading “Entity Framework and Full Text Search”

Managing SQL Server migrations

NuGet package to manage the SQL Server database version

In two projects I recently made a tool for managing the version of the SQL Server database manually. When writing almost the same utility code twice, there would be a third time. So I created a NuGet package to manage the SQL Server version. On start up it checks the database version and then run any upgrade scripts if needed. It also ensures the scripts run only once.
Continue reading “Managing SQL Server migrations”