title: Entity Framework Forcing Distributed Transaction
body: <p>I am unable to get the following code that only touches a single database using a single context to run without escalating to MSDTC, and is throwing an exception on context.SaveChanges():</p>
  
  <pre><code>public void DeleteGroupDetails(int groupId)
  {
      // Note there is no ambient tx
      var thisIsNull = Transaction.Current;
  
      using (var scope = new TransactionScope())
      {
          var thisIsNotNull = Transaction.Current;
  
          using (var context = new MyDbEntities())
          {
              var deleted = context.tblGroups.Where(x =&gt; x.GroupID == groupId);
  
              context.tblGroups.RemoveRange(deleted);
  
              try
              {
                  context.SaveChanges();
              }
              catch (Exception e)
              {
                  Console.WriteLine(e);
              }
          }
  
          //scope.Complete();
      }
  }
  </code></pre>
  
  <p>The exception is "The underlying provider failed on Open. --> The partner transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D025)"</p>
  
  <p>Note:</p>
  
  <ul>
  <li>This is using EF 6 and SQL Server 2005</li>
  <li>Due to a locked down db server I am unable to use MSDTC</li>
  <li>I want to use TransactionScope in the POC because this will be running in WCF, which has TransactionScope built in and I do not want to litter my code with transaction management.</li>
  <li>Similar projects use NHibernate and do not have this problem</li>
  </ul>
  
  <p>Connection string is:</p>
  
  <p>connectionString="metadata=res://<em>/ResourceAccess.MyDb.csdl|res://</em>/ResourceAccess.MyDb.ssdl|res://*/ResourceAccess.MyDb.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=wil-gvpsqldev01;initial catalog=MyDb;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /></p>
  
  <p>System.Transactions diagnostics are:</p>
  
  <pre><code>&lt;E2ETraceEvent&gt;
      &lt;System&gt;
          &lt;EventID&gt;0&lt;/EventID&gt;
          &lt;Type&gt;3&lt;/Type&gt;
          &lt;SubType Name="Information"&gt;0&lt;/SubType&gt;
          &lt;Level&gt;8&lt;/Level&gt;
          &lt;TimeCreated SystemTime="2014-10-31T14:39:43.0061489Z" /&gt;
          &lt;Source Name="System.Transactions" /&gt;
          &lt;Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" /&gt;
          &lt;Execution ProcessName="CCS.Host.Console.vshost" ProcessID="64568" ThreadID="13"/&gt;
          &lt;Channel/&gt;
          &lt;Computer&gt;xxx&lt;/Computer&gt;
      &lt;/System&gt;
          &lt;ApplicationData&gt;
              &lt;TraceData&gt;
                  &lt;DataItem&gt;
                      &lt;TraceRecord Severity="Information"&gt;
                          &lt;TraceIdentifier&gt;http://msdn.microsoft.com/2004/06/System/Transactions/TransactionCreate&lt;/TraceIdentifier&gt;
                          &lt;Description&gt;Transaction Created&lt;/Description&gt;
                          &lt;AppDomain&gt;CCS.Host.Console.vshost.exe&lt;/AppDomain&gt;
                          &lt;ExtendedData&gt;
                              &lt;TraceSource&gt;[Lightweight]&lt;/TraceSource&gt;
                              &lt;TransactionTraceIdentifier&gt;
                              &lt;TransactionIdentifier&gt;2e0814b3-7dd2-4c05-ad69-c3787d95c208:1&lt;/TransactionIdentifier&gt;
                              &lt;CloneIdentifier&gt;1&lt;/CloneIdentifier&gt;
                              &lt;/TransactionTraceIdentifier&gt;
                          &lt;/ExtendedData&gt;
                      &lt;/TraceRecord&gt;
                  &lt;/DataItem&gt;
              &lt;/TraceData&gt;
          &lt;/ApplicationData&gt;
  &lt;/E2ETraceEvent&gt;
  &lt;E2ETraceEvent&gt;
      &lt;System&gt;
          &lt;EventID&gt;0&lt;/EventID&gt;
          &lt;Type&gt;3&lt;/Type&gt;
          &lt;SubType Name="Information"&gt;0&lt;/SubType&gt;
          &lt;Level&gt;8&lt;/Level&gt;
          &lt;TimeCreated SystemTime="2014-10-31T14:39:43.0181489Z" /&gt;
          &lt;Source Name="System.Transactions" /&gt;
          &lt;Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" /&gt;
          &lt;Execution ProcessName="CCS.Host.Console.vshost" ProcessID="64568" ThreadID="13"/&gt;
          &lt;Channel/&gt;
          &lt;Computer&gt;xxx&lt;/Computer&gt;
      &lt;/System&gt;
      &lt;ApplicationData&gt;
          &lt;TraceData&gt;
              &lt;DataItem&gt;
                  &lt;TraceRecord Severity="Information"&gt;
                  &lt;TraceIdentifier&gt;http://msdn.microsoft.com/2004/06/System/Transactions/TransactionScopeCreated&lt;/TraceIdentifier&gt;
                  &lt;Description&gt;TransactionScope Created&lt;/Description&gt;
                  &lt;AppDomain&gt;CCS.Host.Console.vshost.exe&lt;/AppDomain&gt;
                  &lt;ExtendedData&gt;
                      &lt;TraceSource&gt;[Base]&lt;/TraceSource&gt;
                      &lt;TransactionTraceIdentifier&gt;
                      &lt;TransactionIdentifier&gt;2e0814b3-7dd2-4c05-ad69-c3787d95c208:1&lt;/TransactionIdentifier&gt;
                      &lt;CloneIdentifier&gt;2&lt;/CloneIdentifier&gt;
                      &lt;/TransactionTraceIdentifier&gt;
                      &lt;TransactionScopeResult&gt;CreatedTransaction&lt;/TransactionScopeResult&gt;
                  &lt;/ExtendedData&gt;
                  &lt;/TraceRecord&gt;
              &lt;/DataItem&gt;
          &lt;/TraceData&gt;
      &lt;/ApplicationData&gt;
  &lt;/E2ETraceEvent&gt;
  &lt;E2ETraceEvent&gt;
      &lt;System&gt;
          &lt;EventID&gt;0&lt;/EventID&gt;
          &lt;Type&gt;3&lt;/Type&gt;
          &lt;SubType Name="Information"&gt;0&lt;/SubType&gt;
          &lt;Level&gt;8&lt;/Level&gt;
          &lt;TimeCreated SystemTime="2014-10-31T14:39:49.1921489Z"/&gt;
          &lt;Source Name="System.Transactions"/&gt;
          &lt;Correlation ActivityID="{00000000-0000-0000-0000-000000000000}"/&gt;
          &lt;Execution ProcessName="CCS.Host.Console.vshost" ProcessID="64568" ThreadID="13"/&gt;
          &lt;Channel/&gt;
          &lt;Computer&gt;ccc&lt;/Computer&gt;
      &lt;/System&gt;
      &lt;ApplicationData&gt;
          &lt;TraceData&gt;
              &lt;DataItem&gt;
                  &lt;TraceRecord Severity="Information"&gt;
                      &lt;TraceIdentifier&gt;http://msdn.microsoft.com/2004/06/System/Transactions/Enlistment&lt;/TraceIdentifier&gt;
                      &lt;Description&gt;Enlistment Created&lt;/Description&gt;
                      &lt;AppDomain&gt;CCS.Host.Console.vshost.exe&lt;/AppDomain&gt;
                      &lt;ExtendedData&gt;
                          &lt;TraceSource&gt;[Lightweight]&lt;/TraceSource&gt;
                          &lt;EnlistmentTraceIdentifier&gt;
                              &lt;ResourceManagerId&gt;00000000-0000-0000-0000-000000000000&lt;/ResourceManagerId&gt;
                              &lt;TransactionTraceIdentifier&gt;
                                  &lt;TransactionIdentifier&gt;2e0814b3-7dd2-4c05-ad69-c3787d95c208:1&lt;/TransactionIdentifier&gt;
                                  &lt;CloneIdentifier&gt;2&lt;/CloneIdentifier&gt;
                              &lt;/TransactionTraceIdentifier&gt;
                              &lt;EnlistmentIdentifier&gt;0&lt;/EnlistmentIdentifier&gt;
                          &lt;/EnlistmentTraceIdentifier&gt;
                          &lt;EnlistmentType&gt;PromotableSinglePhase&lt;/EnlistmentType&gt;
                          &lt;EnlistmentOptions&gt;None&lt;/EnlistmentOptions&gt;
                      &lt;/ExtendedData&gt;
                  &lt;/TraceRecord&gt;
              &lt;/DataItem&gt;
          &lt;/TraceData&gt;
      &lt;/ApplicationData&gt;
  &lt;/E2ETraceEvent&gt;
  &lt;E2ETraceEvent &gt;
      &lt;System &gt;
          &lt;EventID&gt;0&lt;/EventID&gt;
          &lt;Type&gt;3&lt;/Type&gt;
          &lt;SubType Name="Error"&gt;0&lt;/SubType&gt;
          &lt;Level&gt;2&lt;/Level&gt;
          &lt;TimeCreated SystemTime="2014-10-31T14:39:50.8941489Z" /&gt;
          &lt;Source Name="System.Transactions" /&gt;
          &lt;Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" /&gt;
          &lt;Execution ProcessName="CCS.Host.Console.vshost" ProcessID="64568" ThreadID="13" /&gt;
          &lt;Channel/&gt;
          &lt;Computer&gt;ccc&lt;/Computer&gt;
      &lt;/System&gt;
      &lt;ApplicationData&gt;
          &lt;TraceData&gt;
              &lt;DataItem&gt;
                  &lt;TraceRecord  Severity="Error"&gt;
                      &lt;TraceIdentifier&gt;http://msdn.microsoft.com/2004/06/System/Transactions/TransactionException&lt;/TraceIdentifier&gt;
                      &lt;Description&gt;TransactionException Thrown&lt;/Description&gt;
                      &lt;AppDomain&gt;CCS.Host.Console.vshost.exe&lt;/AppDomain&gt;
                      &lt;ExtendedData xmlns="http://schemas.microsoft.com/2004/03/Transactions/TransactionExceptionTraceRecord"&gt;
                          &lt;TraceSource&gt;[Distributed]&lt;/TraceSource&gt;
                          &lt;ExceptionMessage&gt;The partner transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D025)&lt;/ExceptionMessage&gt;
                      &lt;/ExtendedData&gt;
                  &lt;/TraceRecord&gt;
              &lt;/DataItem&gt;
          &lt;/TraceData&gt;
      &lt;/ApplicationData&gt;
  &lt;/E2ETraceEvent&gt;
  &lt;E2ETraceEvent &gt;
      &lt;System &gt;
          &lt;EventID&gt;0&lt;/EventID&gt;
          &lt;Type&gt;3&lt;/Type&gt;
          &lt;SubType Name="Warning"&gt;0&lt;/SubType&gt;
          &lt;Level&gt;4&lt;/Level&gt;
          &lt;TimeCreated SystemTime="2014-10-31T14:39:50.9591489Z" /&gt;
          &lt;Source Name="System.Transactions" /&gt;
          &lt;Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" /&gt;
          &lt;Execution ProcessName="CCS.Host.Console.vshost" ProcessID="64568" ThreadID="13" /&gt;
          &lt;Channel/&gt;
          &lt;Computer&gt;ccc&lt;/Computer&gt;
      &lt;/System&gt;
      &lt;ApplicationData&gt;
          &lt;TraceData&gt;
              &lt;DataItem&gt;
                  &lt;TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Warning"&gt;
                      &lt;TraceIdentifier&gt;http://msdn.microsoft.com/2004/06/System/Transactions/EnlistmentCallbackNegative&lt;/TraceIdentifier&gt;
                      &lt;Description&gt;Enlistment Callback Negative&lt;/Description&gt;
                      &lt;AppDomain&gt;CCS.Host.Console.vshost.exe&lt;/AppDomain&gt;
                      &lt;ExtendedData &gt;
                          &lt;TraceSource&gt;[Lightweight]&lt;/TraceSource&gt;
                          &lt;EnlistmentTraceIdentifier&gt;
                          &lt;ResourceManagerId&gt;00000000-0000-0000-0000-000000000000&lt;/ResourceManagerId&gt;
                          &lt;TransactionTraceIdentifier&gt;
                              &lt;TransactionIdentifier&gt;2e0814b3-7dd2-4c05-ad69-c3787d95c208:1&lt;/TransactionIdentifier&gt;
                              &lt;CloneIdentifier&gt;2&lt;/CloneIdentifier&gt;
                          &lt;/TransactionTraceIdentifier&gt;
                          &lt;EnlistmentIdentifier&gt;0&lt;/EnlistmentIdentifier&gt;
                          &lt;/EnlistmentTraceIdentifier&gt;&lt;EnlistmentCallback&gt;Aborted&lt;/EnlistmentCallback&gt;
                      &lt;/ExtendedData&gt;
                  &lt;/TraceRecord&gt;
              &lt;/DataItem&gt;
          &lt;/TraceData&gt;
      &lt;/ApplicationData&gt;
  &lt;/E2ETraceEvent&gt;
  &lt;E2ETraceEvent &gt;
      &lt;System &gt;
          &lt;EventID&gt;0&lt;/EventID&gt;
          &lt;Type&gt;3&lt;/Type&gt;
          &lt;SubType Name="Warning"&gt;0&lt;/SubType&gt;
          &lt;Level&gt;4&lt;/Level&gt;
          &lt;TimeCreated SystemTime="2014-10-31T14:39:50.9601489Z" /&gt;
          &lt;Source Name="System.Transactions" /&gt;
          &lt;Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" /&gt;
          &lt;Execution ProcessName="CCS.Host.Console.vshost" ProcessID="64568" ThreadID="13" /&gt;
          &lt;Channel/&gt;
          &lt;Computer&gt;ccc&lt;/Computer&gt;
      &lt;/System&gt;
      &lt;ApplicationData&gt;
          &lt;TraceData&gt;
              &lt;DataItem&gt;
                  &lt;TraceRecord Severity="Warning"&gt;
                      &lt;TraceIdentifier&gt;http://msdn.microsoft.com/2004/06/System/Transactions/TransactionAborted&lt;/TraceIdentifier&gt;
                      &lt;Description&gt;Transaction Aborted&lt;/Description&gt;
                      &lt;AppDomain&gt;CCS.Host.Console.vshost.exe&lt;/AppDomain&gt;
                      &lt;ExtendedData &gt;
                          &lt;TraceSource&gt;[Lightweight]&lt;/TraceSource&gt;
                          &lt;TransactionTraceIdentifier&gt;
                          &lt;TransactionIdentifier&gt;2e0814b3-7dd2-4c05-ad69-c3787d95c208:1&lt;/TransactionIdentifier&gt;
                          &lt;/TransactionTraceIdentifier&gt;
                      &lt;/ExtendedData&gt;
                  &lt;/TraceRecord&gt;
              &lt;/DataIt
  </code></pre>