【发布时间】:2013-06-23 13:06:22
【问题描述】:
考虑这个迁移代码:
CreateTable(
"dbo.Document",
c => new
{
Id = c.Int(nullable: false, identity: true),
Doc = c.String(),
RowGuid = c.Guid(nullable: false),
Person_Id = c.Int(),
})
.PrimaryKey(t => t.Id)
.ForeignKey("dbo.Person", t => t.Person_Id)
.Index(t => t.Person_Id);
我希望RowGuid 是ROWGUIDCOL,并像这样定义(SQL):
[RowGuid] [UNIQUEIDENTIFIER] not null RowGuidCol Unique default newid()
EntityFramework/CodeFirst 中的等效代码是什么?解决办法是什么?
谢谢。
【问题讨论】:
-
有人对此有解决方案吗?我在这个问题上被阻止了。
-
顺便说一句 .. rowguidcol 是做什么的?
-
@vishalsharma,转到以下链接并向下滚动以阅读 Clifford Dibble 的回答:social.msdn.microsoft.com/Forums/sqlserver/en-US/… 本质上它只是标记列,以便可以通过 $ROWGUID 对其进行一般引用。
标签: c# .net sql-server entity-framework ef-code-first