关于c#:newid()作为列默认值

newid() as column default value

本问题已经有最佳答案,请猛点这里访问。

我有一个带有uniqueidentifier列的表。
我应设置什么默认值或绑定以便每个新行生成一个新的uniqueidentifier?

将默认值设置为newid()始终返回00000000-0000-0000-0000-000000000000

编辑:
显然我弄错了,插入是从Entity Framework完成的,它无法处理这种情况。

实体框架-在SQL Server表中未设置默认值


newid()应该起作用。

见下图:

enter image description here

enter image description here

您在那里还有另一个问题。