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

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

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);      
}
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