Page 1 of 1

Autogenerated GUID Primary Key

Posted: Wed 28 Apr 2010 16:19
by jpla2005
Hi all

I'm facing problems working with GUID autogenerated primary keys. I've a table with a Raw(16) primary key wich value is autogenerated using SYS_GUID() oracle function. Th problems is when I insert the first value (without setting the id value for the entity) this id takes a value "00000000000000000000000000000000" and of course, the second call throws an exception because a primary key violation. The problem seems that EF does not recognize this is a autogenerated value and passes the default value of this type when I don't provide another one. Please, how can I solve this problem?

thanks

Posted: Thu 29 Apr 2010 13:59
by AndreyR
Set the StoreGeneratedPattern attribute to "Identity" in the SSDL part of your model for the autoincrement Guid property. This should help.

Posted: Thu 29 Apr 2010 16:54
by jpla2005
Thanks a lot, this works fine.