title: Adding Default Value for New Guid Column in Entity First Migration
body: <p>I am using Entity code first-migrations for my project.  I already have the system up and running.  However, I need to Add a new Guid column which is a foreign key.  While trying to update-Database, I receive the following error:</p>
  
  <blockquote>
    <p>The ALTER TABLE statement conflicted with the FOREIGN KEY constraint
    "FK_dbo.Categories_dbo.aspnet_Roles_RoleId". The conflict occurred in
    database "HelpDesk", table "dbo.aspnet_Roles", column 'RoleId'.</p>
  </blockquote>
  
  <p>So I did some research and found <a href="https://stackoverflow.com/questions/19554050/entity-framework-6-code-first-default-value">Entity Framework 6 Code first Default value</a>.  However, I cannot figure out how to get it to set a default value for the Guid.  Here is the code I tried:</p>
  
  <p>Here is the migration:</p>
  
  <pre><code>public override void Up()
  {
  
       AddColumn("dbo.Categories", "RoleId", c =&gt; c.Guid(nullable: false, defaultValue: "4468ACB7-AD6F-471E-95CF-615115EA3A76"));
       CreateIndex("dbo.Categories", "RoleId");
       AddForeignKey("dbo.Categories", "RoleId", "dbo.aspnet_Roles", "RoleId");
  }
  
  public override void Down()
  {
       DropForeignKey("dbo.Categories", "RoleId", "dbo.aspnet_Roles");
       DropIndex("dbo.Categories", new[] { "RoleId" });
       DropColumn("dbo.Categories", "RoleId");
  }
  </code></pre>
  
  <p>I am able to get rid of all the build errors if I switch to this code (but still gives me that Alter Table error if I run Update-database:</p>
  
  <pre><code>AddColumn("dbo.Categories", "RoleId", c =&gt; c.Guid(nullable: false, identity: false, defaultValue: null));
  </code></pre>
  
  <p>How do I convert this to add a specific Guid as the default value?</p>