title: DDD Entity - are two entities with default identity considered equal
body: <p>I want to apply/practice DDD with my new project hence I am creating those typical DDD base classes, i.e., <code>Entity</code>, <code>ValueObject</code>, <code>AggregateRoot</code> and so on.</p>
  
  <p><strong>Question:</strong>
  When you have the Entity base object implement <code>IEquatable</code>, should two entities with default value of the identity (Id) be considered as <strong>Not equal</strong> or <strong>equal</strong>?</p>
  
  <p>For example, I use <code>Guid</code> type for the identity</p>
  
  <pre><code>public interface IEntity
  {
      Guid LocalId { get; }
  }
  
  public abstract class Entity : IEntity, IEquatable&lt;Entity&gt;
  {
      public Guid LocalId { get; private set; }
  
      protected Entity()
      {
          this.LocalId = Guid.Empty;
      }
  
      protected Entity(Guid id)
      {
          if (Guid.Empty == id)
          {
              id = Guid.NewGuid();
          }
  
          this.LocalId = id;
      }
  
      public bool Equals(Entity other)
      {
          if (ReferenceEquals(other, null))
          {
              return false;
          }
          if (ReferenceEquals(other, this))
          {
              return true;
          }
  
          // **Question** - should I return false or true here?
          if (other.LocalId == Guid.Empty &amp;&amp; this.LocalId == Guid.Empty)
          {
              return false;
          }
  
          return (other.LocalId == this.LocalId);
      }
  
      public override bool Equals(object obj)
      {
          if (ReferenceEquals(obj, null))
          {
              return false;
          }
          if (ReferenceEquals(obj, this))
          {
              return true;
          }
          if (!obj.GetType().Equals(typeof(Entity)))
          {
              return false;
          }
  
          return Equals((Entity)obj);
      }
  
      public override int GetHashCode()
      {
          return this.LocalId.GetHashCode();
      }
  
      public static bool operator==(Entity left, Entity right)
      {
          return Equals(left, right);
      }
  
      public static bool operator!=(Entity left, Entity right)
      {
          return !Equals(left, right);
      }
  }
  </code></pre>