title: System.Data.EntityException: The underlying provider failed on Commit
body: <p>Using Entity Framework, I received a number of the following exceptions last night in one of my applications:</p>
  
  <pre><code>System.Data.EntityException: The underlying provider failed on Commit. ---&gt; 
  System.Data.SqlClient.SqlException: Timeout expired.  The timeout period elapsed prior 
  to completion of the operation or the server is not responding.     
      at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) 
      at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()     
      at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error)
      at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult, TdsParserStateObject stateObj)
      at System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket()     
      at System.Data.SqlClient.TdsParserStateObject.ReadBuffer()     
      at System.Data.SqlClient.TdsParserStateObject.ReadByte()     
      at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler,SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)     
      at System.Data.SqlClient.TdsParser.TdsExecuteTransactionManagerRequest(Byte[] buffer, TransactionManagerRequestType request, String transactionName, TransactionManagerIsolationLevel isoLevel, Int32 timeout, SqlInternalTransaction transaction, TdsParserStateObject stateObj, Boolean isDelegateControlRequest)
      at System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransactionYukon(TransactionRequest transactionRequest, String transactionName, IsolationLevel iso, SqlInternalTransaction internalTransaction, Boolean isDelegateControlRequest)     
      at System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransaction(TransactionRequest transactionRequest, String name, IsolationLevel iso, SqlInternalTransaction internalTransaction, Boolean isDelegateControlRequest)
      at System.Data.SqlClient.SqlInternalTransaction.Commit()     
      at System.Data.SqlClient.SqlTransaction.Commit()
      at System.Data.EntityClient.EntityTransaction.Commit()     
      --- End of inner exception stack trace ---     
      at System.Data.EntityClient.EntityTransaction.Commit()     
      at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)     
      at System.Data.Entity.Internal.InternalContext.SaveChanges()     
      at System.Data.Entity.Internal.LazyInternalContext.SaveChanges()
  </code></pre>
  
  <p>What's interesting about this error is that the data was actually written to the database. I <a href="http://social.msdn.microsoft.com/Forums/is/adodotnetentityframework/thread/34159afb-9820-43fb-8ac8-bd3e287d8b6a">found a related post on a MS site</a> that seemed to indicate that this was a network related error.</p>
  
  <p>A few questions that I could use assistance on are:</p>
  
  <ol>
  <li>What options do I have to trouble shoot this error?</li>
  <li>Is it more than likely network related or could the DB be a suspect?</li>
  <li>How can I tell from the code whether the transaction really did complete?</li>
  <li>Should I query the DB on this error to check if success or simply retry the transaction?</li>
  <li>If I do retry the transaction, how can this be accomplished automatically with Entity Framework or do I simply catch/retry?</li>
  <li>What other items should I be looking at?</li>
  </ol>
  
  <p>Thanks in advance.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Using <a href="http://www.confio.com/English/Products/Ignite_for_SQL_Server.php">Ignite for SQL</a> we were able to determine that a secondary SQL process from another group was monopolizing the CPU preventing our application from functioning properly. In short, we're moving forward with adding a secondary server to prevent further conflicts between the two teams.</p>
  
  <p>What's still interesting about the exception is that the transaction actually succeeded rather than failed.</p>