Entity Framework update/insert multiple entities : <p>Just a bit of an outline of what i am trying to accomplish.
We keep a local copy of a remote database (3rd party) within our application. To download the information we use an api.
We currently download the information on a schedule which then either inserts new records into the local database or updates the existing records.
here is how it currently works</p>

<pre><code>public void ProcessApiData(List&lt;Account&gt; apiData)
{
     // get the existing accounts from the local database
     List&lt;Account&gt; existingAccounts = _accountRepository.GetAllList();

     foreach(account in apiData)
     {
         // check if it already exists in the local database
         var existingAccount = existingAccounts.SingleOrDefault(a =&gt; a.AccountId == account.AccountId);

         // if its null then its a new record
         if(existingAccount == null)
         {
             _accountRepository.Insert(account);
             continue;
         }

         // else its a new record so it needs updating
         existingAccount.AccountName = account.AccountName;

         // ... continue updating the rest of the properties
     }

     CurrentUnitOfWork.SaveChanges();
}
</code></pre>

<p>This works fine, however it just feels like this could be improved.</p>

<ol>
<li>There is one of these methods per Entity, and they all do the same thing (just updating different properties) or inserting a different Entity. Would there be anyway to make this more generic?</li>
<li>It just seems like a lot of database calls, would there be anyway to "Bulk" do this. I've had a look at this package which i have seen mentioned on a few other posts <a href="https://github.com/loresoft/EntityFramework.Extended" rel="noreferrer">https://github.com/loresoft/EntityFramework.Extended</a>
But it seems to focus on bulk updating a single property with the same value, or so i can tell.</li>
</ol>

<p>Any suggestions on how i can improve this would be brilliant. I'm still fairly new to c# so i'm still searching for the best way to do things.</p>

<p>I'm using .net 4.5.2 and Entity Framework 6.1.3 with MSSQL 2014 as the backend database</p>
