TransactionScope promoting to MSDTC although I am using the same connection string
entity-framework-4.3, msdtc, sql-server-2008-r2, transactions, transactionscope
Solution
Ok, I found why. Entity Framework is modifying my connection string to:
"Data Source=(local);Initial Catalog=mydb;User Id=myid;Password=mypass;Asynchronous Processing=true;Application Name=EntityFrameworkMUE"
And that is causing the promotion to MSDTC!
In order to avoid this, I have set up my own "Application Name" in the connection string and it works now.
Cheers.
Problem
I have two repositories that point to the same SQL Server 2008 R2 (10.50.2550.0) database. One repository is based on Entity Framework, the other uses regular SqlConnection. I need to perform an operation that involves both, so I have used a `TransactionScope` to keep them in the same transaction: ``` using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions() { IsolationLevel = IsolationLevel.RepeatableRead })) { _repoA.DoStuff(); _repoB.DoStuff(); } ``` Since I use the same connection string in both: ``` "Data Source=(local);Initial Catalog=mydb;User Id=myid;Password=mypass;Asynchronous Processing=true" ``` I was expecting that SQL Server 2008 R2 could use multiple connections without scalating. Unfortunately I get an exception saying: System.Data.SqlClient.SqlException occurred Message=MSDTC on server 'MyComputer' is unavailable. Source=.Net SqlClient Data Provider ErrorCode=-2146232060 Class=16 LineNumber=1 Number=8501 Procedure="" Server=(local) State=2 StackTrace: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) What could be the problem? Cheers.