Ensure Uniqueness of Nullable Columns

A couple of weeks ago I encountered a tweet in which one of the questions expected from a candidates in a job interview was the reason to write this post, How do you ensure that duplicate keys are prevented on a column that allows NULL values?

That reminds me of the time that I was focused on databases and I had to handle such problem for one of our databases, here we are going to talk about two approaches to address this issue in SQL Server.

Read More

Explore Shadow Properties in EF Core

In the previous post we discovered Query Filters, a feature for EF Core 2.0 and later. Now I want to take a look at another popular feature Shadow Properties. When designing applications we tend to keep our code clean and simple, however there are times that you need to add properties other than what is required in your main business use cases, CreatedOn and LastUpdatedOn are such well-known properties.

Read More

Explore Global Query Filters in EF Core

In this article we are going to check one of the features of Entity Framework Core, Global Query Filters; this was introduced first in EF Core 2.0 and is just a query predicate that will be appended to the end of where clause for queries on entities for which this feature has been activated. Some common scenarios would be Soft delete and Multi tenancy.

Consider that you are writing an application in which entities can be soft deleted, why not completely delete those entities?

Read More