介尘部落

文学|音乐|休闲娱乐|计算机技术|地球科学|社会学——知识成就命运


Entity Framework code first newsequentialid() Guid 主键

If you are using migrations you should be able to simply modify code based migration to use newsequentialid() as DefaultValueSql.

[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public override void Up() {
    CreateTable(
        "SomeTable",
         c => new {
            Id = c.Guid(nullable: false, defaultValueSql: "newsequentialid()"),
         })
         .PrimaryKey(t => t.Id)
    );
}
阅读全文
公众号-介尘阅读时光
赞赏支持

0 Responses to “Entity Framework code first newsequentialid() Guid 主键”

Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

×