ayende/ravendb — pull request #1762 by talweiss1982 (2014-12-30 11:49:25+00:00)
Title: ShardedDocumentStore generates wrong Id's when storing an existing document 

I have decided to change the callback that modifies the document id.
The only use of it in the code is in BaseShardedDocumentSession:

protected string ModifyObjectId(string id, object entity, RavenJObject metadata)
{
var shardId = shardStrategy.ShardResolutionStrategy.GenerateShardIdFor(entity, this);
if (string.IsNullOrEmpty(shardId))
throw new InvalidOperationException("Could not find shard id for " + entity + " because " + shardStrategy.ShardAccessStrategy + " returned null or empty string for the document shard id.");
metadata[Constants.RavenShardId] = shardId;
var modifyDocumentId = shardStrategy.ModifyDocumentId(Conventions, shardId, id);
if (modifyDocumentId != id)
GenerateEntityIdOnTheClient.TrySetIdentity(entity, modifyDocumentId);

return modifyDocumentId;
}

from the code it seems that the method ModifyDocumentId may return the original id and the behavior is as expected.