title: Insert and update multi item into database in the same time
body: <p>I have an empty data base.
  I want to add multi records into data base.
  while inserting record to data base i want to check if my product inserted in same date donot add it again(i want to change some it's filed and update it's content).
  i used this code but it just add some data into data base (it can't check for existing product.)</p>
  
  <pre><code>var AllData = ClsDataBase.Database.InsertProductTbls;
  
   foreach(item in AllData)
          {
            //Update  
            if (Exist(datefa))
              {
              var query = ClsDataBase.Database.CustomerProductTbls.SingleOrDefault
                      (data =&gt; data.CustomerId == AllData .CustomerId );
  
                      int? LastProductTotal = query.CustomerProducTtotal;
                      query.CustomerProducTtotal = LastProductTotal + ClsInsertProduct._InsertProductNumber;
  
                  }
                  //Insert 
                  else
                  {
                      _CustomerProductTbl = new CustomerProductTbl();
                      _CustomerProductTbl.CustomerId = AllData ._CustomerId;
                      _CustomerProductTbl.CustomerProductDateFa = AllData.datefa
                      .
                      .
                      .
                      ClsDataBase.Database.AddToCustomerProductTbls(_CustomerProductTbl);
                  }
              }
          }
          ClsDataBase.Database.SaveChanges();
  </code></pre>
  
  <p>if i use <code>ClsDataBase.Database.SaveChanges();</code> for both update and insert part i will return this error:</p>
  
  <pre><code>An error occurred while starting a transaction on the provider connection. See the inner exception for details.
  </code></pre>
  
  <p>please help.</p>