Entity Framework 6: Turn off Sequential GUIDs

entity-framework-6 guid sequential

Question

Entity Framework 6 appears to default to sequential GUIDs instead of completely random ones. How do I turn this off?

See CodePlex work item: http://entityframework.codeplex.com/workitem/71

Popular Answer

From the changeset linked to that work item, you'll see that the GuidColumnDefault isn't based on any settings, but just returns the default based on the provider type

Looking at this link, it would appear you can set it manually 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);      
}



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why