Entity Framework 6: Turn off Sequential GUIDs

entity-framework-6 guid sequential

Question

Entity Framework 6 seems to use sequential GUIDs by default rather than totally random ones. How can I shut off this?

http://entityframework.codeplex.com/workitem/71 is a work item on CodePlex.

1
2
10/15/2013 4:19:57 AM

Popular Answer

You can see that the changeset attached to that work item shows that theGuidColumnDefault does not depend on any settings; instead, it just returns the default based on the kind of provider.

It appears from this link that you can manually set it in your migrations, though:

// Excerpt from migration in link above:
public override void Up()
{
    CreateTable(
        "dbo.Items",
        c => new
            {
                Id = c.Guid(nullable: false,
                    identity: true,
                    // You would use newid() instead.
                    defaultValueSql: "newsequentialid()"),
            })
        .PrimaryKey(t => t.Id);      
}
2
10/18/2013 4:36:38 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow