EF migrations and timestamp column, cannot update/run
.net, c#, entity-framework, entity-framework-6
Solution
Replace one line `AlterColumn` with 2 lines `DropColumn` and `AddColumn` in Up() method.
public override void Up()
{
DropColumn("dbo.Cities", "RowVersion", null);
AddColumn("dbo.Cities", "RowVersion", c => c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"));
}
public override void Down()
{
AlterColumn("dbo.Cities", "RowVersion", c => c.Binary());
}
Problem
I have an object in EF6 that i forgot to inherit from my auditableEntity class. This class has a configuration like so ``` public abstract class AuditableEntityConfig<TEntity> : BaseEntityConfig<TEntity> where TEntity : AuditableEntity { public AuditableEntityConfig() : base() { this.Property(e => e.RowVersion) .IsRowVersion(); } } ``` Now i have updated my entity to inherit from this class and now upon running my code, i always get an error saying ``` Cannot alter column 'RowVersion' to be data type timestamp. ``` Is there anyway i can stop EF trying to set this column to be timestamp, and maybe i drop and recreate the table myself instead?