title: DbUpdateConcurrencyException: 'Database operation expected to affect 1 row(s) but actually affected 43 row(s)' when updating entities
body: <p>I'm trying to update database data but I'm facing a problem that I've never seen before. I usually use this approach to update data, but this time I got this error and I would like to better understand why and how to solve it:</p>
  <pre><code>//this entity has a primary key consisting of 3 columns in the database
  var exists =  await _context.Relatives
      .Where(x =&gt; x.Company== companyId)
      .Where(x =&gt; x.Person== personId)
      .Where(x =&gt; x.Cpf == familiar.Cpf)
      .FirstOrDefaultAsync();
  
  if (exists != default)
  {
      exists.Cpf = familiar.Cpf;
      exists.Nome = familiar.Name;
      //there are other props here
  }
  
  await _context.SaveChangesAsync();
  </code></pre>
  <p>When executing <code>SaveChangesAsync()</code>, this error appears: <code>Database operation expected to affect 1 row(s) but actually affected 43 row(s). Data may have been modified or deleted since entities were loaded</code>. Could someone help me better understand which part of my code is generating this error?</p>
  <p>When doing <code>_context.Relatives.Update(exists)</code> before <code>SaveChangesAsync()</code>, the following error appears: <code>Violation of PRIMARY KEY constraint 'RH_PK_3160'. Cannot insert duplicate key in object 'dbo.X'</code>, and I didn't update any of the primary keys, only other properties.</p>