I have a table with a non-PK rowguidcol column like this:
CREATE TABLE [dbo].[SomeTable] (
...
RowGuid uniqueidentifier NOT NULL DEFAULT (NEWSEQUENTIALID()) ROWGUIDCOL,
...
CONSTRAINT AK_SOMETABLE_ROWGUID UNIQUE (RowGuid)
...
)
When I try to add a record through EF (version 4.3.1), the following exception is raised:
Violation of UNIQUE KEY constraint 'AK_SOMETABLE_ROWGUID'. Cannot insert duplicate key in object 'dbo.SomeTable'.
The duplicate key value is (00000000-0000-0000-0000-000000000000).
I am leaving the RowGuid field as null. But it seems EF is zeroing out the guid column value.
How do I tell EF that the new row should be populated by NEWSEQUENTIALID() at server level?
Update: After reading this blog post, I set the StoreGeneratedPattern property to "Identity" in the EDM designer. It seems to be working now.
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