How to automatically add base class to table mapped classes and data context in LINQ to SQL

I always tend to use LINQ to SQL (L2S) in smaller projects rather than Entity Framework (EF), it’s more lightweight and provides faster development for projects of this scope. Of course, for more robust system I would go with EF because of the better control and the relations between the context objects. If you like to go more into details on this read this topic: L2S vs Ef.


Inheritance is much easier to implement in EF but it can also be done in L2S although in a not very clean way, at least not that I know of. Here I’ll show you how can you add a base class to the L2S entities that can be used for auditing, creating domain events or whatever behavior that you want to achieve across all entities.Read More »

Lock, Block and Two Concurrent Processes

Recently I had a deadlock or blocking of my Microsoft SQL database while using Entity Framework, of course, it was a bad piece of code that was causing that block. After the blocking occurred I started getting timeout exception for every database action that I wanted to do, even for the basic most simple one queries.


This specific issue will not be the topic of this article but something more general like what are and why blocks appear, how to detect which is the process that is causing the blocking and what you need to do to stop that process on a database level.Read More »