Quantcast
Viewing all articles
Browse latest Browse all 132

Adding ROWGUIDCOL to Entity Framework Code First using migrations

To add add a ROWGUIDCOL to a unique identifier in a table using code first you have to use code migrations.

Below is the snippet you need. I haven’t covered how to perform a migration because there are plenty of articles available.

public partial class AddRowGuidCol : DbMigration
{
   public override void Up()
   {
      Sql("ALTER TABLE dbo.Address ALTER COLUMN [AddressID] ADD ROWGUIDCOL");
   }

   public override Void Down()
   {
      Sql("ALTER TABLE dbo.Address ALTER COLUMN [AddressID] DROP ROWGUIDCOL");
   }
}


Viewing all articles
Browse latest Browse all 132

Trending Articles