locked
How to generate a GUID as Default Value for a property or is it even possible? RRS feed

  • Question

  • I'm currently creating a custom configuration item and I want to have a key property that is a GUID. I just want to ask if it is possible to set the default value to generate a random GUID similar to how you set an incrementing integer value or an Int type property. 

    Thanks,

    Neil

    Monday, April 30, 2012 3:06 PM

All replies

  • What's wrong with the default Id property which is a Guid? Actually, I have a custom class where I used a Guid as the key, however, instances of this class are always created programmatically and I use Guid.NewGuid for this. As far as I can tell, making a property the key just means it can't be null and is unique, it's not actually created as a key in the database. BaseManagedEntityId just gets created as the clustered index key. I haven't ever tried setting AutoIncrement=True to see what happens...

    Rob Ford scsmnz.net





    • Edited by Rob.Ford Tuesday, May 1, 2012 7:42 AM
    Tuesday, May 1, 2012 7:22 AM