title: Entity Framework Core Transactions
body: <p>I am using big transaction in my application. This transaction contains alot of SaveChanges() in diffrent tables. </p>
  
  <p>I am using repository pattern and this is pseudocode of what I have:</p>
  
  <pre><code>public async Task&lt;Event&gt; AddEvent(int eventId, string eventData)
  {
      using(var transaction = await _eventRepository.BeginTransactionAsync())
      {
          try
          {
              //some more operations..
              await EventFactory.HandleEventAsync(eventId) // &lt;-- This line call factory to do alot of things in diffrent tables with using SaveChanges() methods and so it uses other repositories
              //some more operations..
          }
          catch(Exception ex)
          {
              transaction.Rollback()
          }
  
      }
  }
  </code></pre>
  
  <p>I am using one context in all repositories each API call. The point is sometimes it seems that transaction did not rollback the changes. However this is really non-deterministic because this happens in production one time per day~.</p>
  
  <p>I am using Entity Framework Core 1.1. </p>
  
  <p>I really cannot find the issue in the code because when someting fails then there is a rollback but sometimes I see abnormal data in database.</p>
  
  <p>Did somone faced similiar problem using EF Core?</p>