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.

 1public partial class AddRowGuidCol : DbMigration
 2{
 3   public override void Up()
 4   {
 5      Sql("ALTER TABLE dbo.Address ALTER COLUMN [AddressID] ADD ROWGUIDCOL");
 6   }
 7
 8   public override Void Down()
 9   {
10      Sql("ALTER TABLE dbo.Address ALTER COLUMN [AddressID] DROP ROWGUIDCOL");
11   }
12}
comments powered by Disqus

Related