开发者

Is it possible to set column default to SQL Server's NewId()?

In fluentMigrator, is it possible to set a column default to a function?

Specifically, I'm adding a uniqueidentifier (Guid) column to a SQL S开发者_运维技巧erver 2008 table that already contains data, and it's going to be a required field - is it possible to set the default to the NewId() function?


Field defaults for NewId() and GetDate() are available (for SQL Server at least) by referring to either SystemMethods.NewGuid or SystemMethods.CurrentDateTime, for example:

Create
    .Column("incomeIdGuid").OnTable("tblIncome")
    .AsGuid()
    .NotNullable()
    .WithDefaultValue(SystemMethods.NewGuid);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜