I am creating a custom data provider to integration news articles from an external API into a Sitecore solution.

The external data source use simple integers as ID for the news articles though. I will be running the data provider in "live mode" (directly in both master and web databases without publishing). How do i generate consistent GUIDs from the ID, so that the GUID will be the same across both databases?

3 Answers 3


Sitecore Commerce Connect employs a similar approach. From the Commerce Connect Integration Guide:

3.1.5 ID Mapping By design, the remote product repository is always regarded as the main repository, which by default owns the products.

That makes the ID of the products and artifacts in the external system the primary key.

In Sitecore, the IDs of the corresponding items for products and artifacts are generated by Connect instead of relying on the default Sitecore implementation that automatically generates a new GUID for each new item created.

By using a hash algorithm, it is possible to generate a direct mapping between the IDs coming from the external system and the item IDs in Sitecore. It has the following benefits:

  • No need for mapping tables taking up space.
  • It becomes very fast to get the ID of the corresponding item.
  • There is no need for searching for the items in Sitecore if the external ID is provided.

The default implementation is based on the MD5 hash algorithm and has the following format:

Item.ID = MD5.ComputeHash(Prefix + ExternalID);

So essentially; make a Sitecore ID based on prefix (which would be your entity type; "product", "category", "customer" and so on) and the foreign unique key of the entity. That should bring you to the same ID result every time.


You should try to write a function to generate deterministic guids. Found this: http://kechengpuzi.com/q/s2642141 as a possibility (example is based on paths, but you can use your id as input - if needed with a pre- or suffix).

It actually comes down to creating a hash and calling the Guid constructor with that.

I did not copy the example code here as they mention a few possible solutions and I didn't try them myself so it's not clear which is best.


I have had to do similar in the past have used deterministic GUIDs. I use the method described and shared here:


This algorithm follows RFC 4122, and is designed not to clash with GUIDs that are generated in other namespaces - so it won't clash with Guid.NewGuid() for example.

Using MD5 hashes directly works but they don't come with the guarantee of avoiding clashes with other GUIDs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.