I want to add a column of type BIT
to an existing table with a default value of 1
via migrations. The challenge is ... we have in the company a default for the name of constraints
and it is not legal the name automatically created by EF.
Below the code to add the column:
public override void Up()
{
AddColumn("dbo.RODADA_DESAFIO", "FL_STATUS", c => c.Boolean(nullable: false, defaultValue: true));
}
Is there any parameter I can pass in AddColumn
to set the name of constraint
default or some other way to do this?
I've tried it this way:
public override void Up()
{
AddColumn("dbo.RODADA_DESAFIO", "FL_STATUS", c => c.Boolean(nullable: false))
Sql("ALTER TABLE RODADA_DESAFIO ADD CONSTRAINT DF_RODADADESAFIO_STATUS DEFAULT (1) FOR FL_STATUS");
}
However, the following error appears:
Column already has a DEFAULT bound to it.
Could not create constraint or index. See previous errors.
NOTE: The column does not yet exist in the database.