//Identity key depends on object primary kyes and type hash codes public int GetIdentityKey() { if (Status == ObjectStatus.New) { return(ObjectGuid.GetHashCode()); } else { int primaryKeysHashcode = (GetPrimaryKey().Value ?? 0).GetHashCode(); return(primaryKeysHashcode ^ GetType().GUID.GetHashCode()); } }