I have an original class that looks like the following:
using System.ComponentModel.DataAnnotations;
public class TestClass
{
[Range(1, 10)]
public int TestValue { get; set; } = 0;
}
That I am trying to change to include 0 as an option, or just no Range at all.
using System.ComponentModel.DataAnnotations;
public class TestClass
{
[Range(0, 10)]
public int TestValue { get; set; } = 0;
}
Then I run the following EF command and there are no changes picked up.
EntityFramework6\add-migration -Name constraintFix -ConfigurationTypeName TestProject.Infrastructure.EntityFramework.Migrations.Configuration
Will this have to be done with SQL manually or am I missing something?
CodePudding user response:
remove your last migrations and add a new migration
CodePudding user response:
I ended up removing the column, ran a migration to get the SQL it auto-generated. I then removed that migration, made my changes to the class, ran a migration (no SQL was generated as expected). I then added back in the SQL it generated to remove the constraint manually. This seems to have worked in my case. Hopefully some day there will be a better answer to this.