How to add multiple entities of the same type in single EF save changes?
<p><strong>Issue</strong></p>

<p>When attempting to save multiple database entities in a single SaveChanges() call I receive the following error:</p>

<blockquote>
  <p>Saving or accepting changes failed because more than one entity of type 'Example.Data.QuestionCategory' have the same primary key value. Ensure that explicitly set primary key values are unique. Ensure that database-generated primary keys are configured correctly in the database and in the Entity Framework model. Use the Entity Designer for Database First/Model First configuration. Use the 'HasDatabaseGeneratedOption" fluent API or 'DatabaseGeneratedAttribute' for Code First configuration.</p>
</blockquote>

<p><strong>Example code</strong></p>

<pre><code>using (var context = new DatabaseEntities())
{
    var category = new QuestionCategory()
    {
        Name = "Test 1"
    };
    context.QuestionCategories.Add(category);
    var child = new QuestionCategory()
    {
        Name = "Test 2",
    };
    context.QuestionCategories.Add(child);
    context.SaveChanges();
}
</code></pre>

<p><strong>Additional Info</strong></p>

<p>We are using an entity framework 6 model generated from a database table where the ID column is an identity column.</p>

<p>Does anyone know how to get around this issue without specifically saving after each item is added (this is just an example of a much larger code block)?</p>