Posts

Showing posts from September 8, 2013

Avoid DTC call in Entity Framework 4 on SQL Server 2005

Ok really went down a rabbit hole today but I managed to crawl back out.  I went to create a database connection test. It consisted of first creating a transaction and then select a count of the number of records that match the record I was about to add, add the record, then count again to make sure the count is now different from the first count. This triggered a distributed transaction coordinator(DTC) error because I didn't have distributed transactions turned on but I didn't want it to start a distributed transaction as they add processing time and are not needed in this scenario.  So after much research I've discovered this apparently wouldn't have occurred if I was using SQL Server 2008 or greater but I of course was connecting to 2005. In Entity Framework 6(EF6) it looks like they are finally giving us the option to tell the Entity Framework to use an existing transaction and not force a distributed one. Which will be nice when EF6 is released and I upgrade