title: Warning: "... overrides Object.Equals(object o) but does not override Object.GetHashCode()"
body: <p>I overrode the Equals() of my class to compare ID values of type Guid.</p>
  
  <p>Then Visual Studio warned:</p>
  
  <blockquote>
    <p>... overrides Object.Equals(object o) but
    does not override Object.GetHashCode()</p>
  </blockquote>
  
  <p>So I then also overrode its GetHashCode() like this:</p>
  
  <pre><code>public partial class SomeClass
  {
      public override bool Equals(Object obj)
      {
          //Check for null and compare run-time types.
          if (obj == null || this.GetType() != obj.GetType()) return false;
  
          return this.Id == ((SomeClass)obj).Id;
      }
  
      public override int GetHashCode()
      {
          return this.Id.GetHashCode();
      }
  }
  </code></pre>
  
  <p>It seems to work. <strong>Have I done this correctly?</strong> Remember Id is of type Guid. <strong>Does it matter that my class is an Entity Framework object?</strong></p>