However, MERGE originally shipped with several "wrong results" and other bugs - some of which have been addressed, and some of which continue to exist even in the early preview releases of SQL Server 2014.People also tend to make some leaps of faith regarding atomicity - they don't realize that the single statement actually performs different operations separately, and thus can suffer from issues due to concurrency and race conditions just like separate statements can.
This is a minor and subjective gripe, but I've always found the Merge syntax quite daunting and difficult to memorize.
I can't imagine there are many people out there who can write a fully-featured MERGE statement without consulting Books Online, and without going through many more cycles of testing to verify that all branches function as expected.
The section below is the same for entities in an inheritance hierarchy as for entities not in an inheritance hierarchy, unless stated otherwise.
The base class, generally named Entity Name Entity Base.cs/vb, for example Order Entity Base.cs, is the class containing all the logic and the implementations of various methods defined in the Entity Base class in the ORMSupport Classes namespace.
This class is the base class for all generated entity classes and it derives from the class Entity Base, which is located in the ORMSupport Classes assembly.
The Common Entity Base class is usable to add code (via a partial class or using the user code regions) to all generated entities without having to generate / add that code to all entity classes separately.
The pattern should be: Due to those same mechanics, converting your insert/update/delete code should be thoroughly tested when triggers are involved.
Prevailing wisdom has instilled in most of us the mindset that, in SQL Server, triggers fire once per statement. My Table FOR INSERT, UPDATE, DELETE AS BEGIN PRINT 'Executing trigger.
However, under the covers, SQL Server really does perform the different operations independently.
This means that you could end up with race conditions or primary key conflicts when multiple users are attempting to fire the same MERGE statement concurrently.
This base class derives from the central generated base class Common Entity Base.