title: Check if the entities have same properties
body: <p>I'm in a bit of a pickle and I shall describe it here. I have a foreach loop in which I insert rows in my table. But before inserting, I want to check if I already have a row with the same ID, and if so, if the other properties (columns) are of the same values.</p>
  
  <p>This is what I do:</p>
  
  <pre><code>var sourceList = LoadFromOtherDataBase();
  var res = ListAll(); // Load all rows from database which were already inserted...
  
  
  foreach (Whatever w in sourceList)
  {
     Entry entry = new Entry();
  
     entry.id = w.id;
     entry.field1 = w.firstfield;
     entry.field2 = w.secondfield;
     //so on...
  
     //Now, check if this entry was already inserted into the table...
  
     var check = res.Where(n =&gt; n.id == entry.id);
  
     if (check.Count() &gt; 0)
     {
       var alreadyInserted = res.Single(n =&gt; n.id == entry.id);
       //Here, I need to see if 'alreadyInserted' has the same properties as 'entry' and act upon it. If same properties, do nothing, otherwise, update alreadyInserted with entry's values.
     }
     else
     {
        //Then I'll insert it as a new row obviously....
     }
  
  
  }
  </code></pre>
  
  <p>I have thought of Object.Equals() but Entity Framework creates a non-null <em>EntityKey</em> property for <strong>alreadyInserted</strong>, which is set to null in <strong>entry</strong>. Which I think is why it's not working. <em>EntityKey</em> cannot be set to null.</p>
  
  <p>Any ideas on how to do this without having to check all properties (25+ actually in my case) by hand ?</p>