locked
Nullable Guid: default = null RRS feed

  • Question

  • I need to set nullable FK default value to null, but when I`m trying to set it using model designer validation fails with following message:

    "Default value (null) is not valid for GUID. The value must be enclosed in single quotes in the form 'dddddddd-dddd-dddd-dddd-dddddddddddd'."

    What must I do in this case? Just set '00000000-0000-0000-0000-000000000000'?

    P.S. Sorry for foolish question

    Thursday, May 17, 2012 12:36 PM

Answers

  • Hi AlikDev,

    For both SQL Server and the CLR the default value for any nullable field is null. So I don't see why you would need to specify the default value to null. Is there some reason I'm not seeing? Otherwise you should be fine to just leave the field with no default set.

    Regards,

    Tyler

    Thursday, May 17, 2012 1:42 PM

All replies

  • Hi AlikDev,

    For both SQL Server and the CLR the default value for any nullable field is null. So I don't see why you would need to specify the default value to null. Is there some reason I'm not seeing? Otherwise you should be fine to just leave the field with no default set.

    Regards,

    Tyler

    Thursday, May 17, 2012 1:42 PM
  • I`m trying to handle cascade operations manually based on the model (there are reasons to do it). Anyway, you are right, it looks ok to assume default value == null for nullable foreign keys without explicit default value.

    Thursday, May 17, 2012 2:23 PM