我有一个带有非PK rowguidcol列的表,如下所示:
CREATE TABLE [dbo].[SomeTable] (
...
RowGuid uniqueidentifier NOT NULL DEFAULT (NEWSEQUENTIALID()) ROWGUIDCOL,
...
CONSTRAINT AK_SOMETABLE_ROWGUID UNIQUE (RowGuid)
...
)
当我尝试通过EF(版本4.3.1)添加记录时,会引发以下异常:
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).
我将RowGuid字段保留为null。但似乎EF正在将guid列值归零。
如何告诉EF在服务器级别应该由NEWSEQUENTIALID()填充新行?