What logic determines the insert order of Entity Framework 6
<p>So, I have a DBContext, and I am doing the following operations:</p>

<pre><code>dbContext.SomeTables1.Add(object1)
dbContext.SomeTables2.AddRange(objectArray2)
dbContext.SomeTables3.AddRange(objectArray3)
dbContext.SaveChanges();
</code></pre>

<p>The EF doesn't insert the db records in this order, it inserts them in a random order. To insert them in the same order, I have to do a <code>dbContext.SaveChanges()</code> after each addition. This is not an efficient solution and in my case, it is taking 10 seconds to do all my inserts, while the random order with one save takes around 3 seconds.</p>

<p>N.B. I need the right order to solve a deadlock issue.</p>

<p>My questions are:</p>

<blockquote>
  <ul>
  <li>Is this issue resolved in EF7?</li>
  <li>I can profile EF and determine the random order, however, is there a guarantee that it will be consistently with the same random order or
  does it change between requests? (I can adopt my other code if the
  answer to this question is positive).</li>
  <li>Is there a better way of maintaining the order than <code>dbContext.SaveChanges()</code> on every addition?</li>
  </ul>
</blockquote>