title: Data Saves in EF7 with One Object - Not With Many
body: <p>I have a an object model in EF7 that looks something like this:</p>
  
  <pre><code>Story -&gt; StoryPhotos[]
  </code></pre>
  
  <p>I build the model through a form submission of a story where a user may also attach N number of photos. The model creation looks something like this:</p>
  
  <pre><code>var story = new Story
  {
    // ...
  
    StoryPhotos = myFormData.Photos.Select(p =&gt; new StoryPhoto {
      Name = p.Name,
      FileName = p.FileName,
      etc.
    }).ToList()
  }
  </code></pre>
  
  <p>Then, once I have built my data models, I save the data via a repository.</p>
  
  <pre><code>await repository.AddOrUpdateStoryAsync(story)
  </code></pre>
  
  <p>which looks like this</p>
  
  <pre><code>if (story.Id == 0)
  {
      context.Stories.Add(story);
      context.StoryPhotos.AddRange(story.StoryPhotos);
  }
  else
  {
    // Update properties for an edit.
  }
  await context.SaveChangesAsync();
  </code></pre>
  
  <p>This works great...as long as I only have a single StoryPhoto. As soon as I put more than one into the array, I get this exception:</p>
  
  <pre><code>An unhandled exception occurred while processing the request.
  
  SqlException: Incorrect syntax near ','.
  System.Data.SqlClient.SqlCommand.&lt;&gt;c__DisplayClass16.&lt;ExecuteDbDataReaderAsync&gt;b__17(Task`1 result)
  </code></pre>
  
  <p>My research shows that there have been a few different issues with regards to how EF7 is saving object graphs, but I am confused in the case where one saves fine and more than one doesn't, with no other changes to the code.</p>
  
  <p>I am using EntityFramework-SqlServer 7.0.0-beta7.</p>