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.