I was using the SDK for CRM, and printed out the PK on a bunch of instances of one of our entities. I repeated it with the database's filtered views, and got the same answer:
1a6c691d-391a-de11-8b0e-0050568407cb bd7b0ff0-391a-de11-8b0e-0050568407cb ed272bfe-391a-de11-8b0e-0050568407cb ... and so on ...
These don't appear to be valid GUIDs. For one, they LOOK wrong - they're nearly identical, a property that GUIDs haven't had since the old version 1 & 2 GUIDs that were based on MAC addresses and clock time. Moreover, however, is the fact that a certain nibble in a GUID indicates the GUID's version - that nibble is incorrect here. (First nibble of the third section, ie: 1a6c691d-391a-**d**e11-8b0e-0050568407cb) - valid values are 1-5) (Generate a GUID using MS's GUID Generator - that slot will always be 4. (At least for the version I have.))
Are these GUIDs, or just IDs, and how do I know?
You are right that they are GUIDs and that they are sequential. These keys are not generated by CRM. They are generated by SQL Server.
SQL Server has a GUID type called uniqueidentifier. It can be configured as either NEWID() or NEWSEQUENTIALID(). NEWID() will generate a new GUID every time. NEWSEQUENTIALID() generates a GUID the first time and then sequentially increments it on subsequent database inserts.
So you have discovered that Dynamics CRM is configured for NEWSEQUENTIALID().
More info about this is here: http://www.mssqltips.com/tip.asp?tip=1600
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With