My model contains, among other things, two properties that were added to the model class after its initial creation and migration.
public sealed class SomeModel
{
... other properties, which are fine.
public int PropertyOne { get; set; }
public int PropertyTwo { get; set; }
}
My last migration contains:
public override void Up()
{
... other table being created.
AddColumn("dbo.SomeModel", "PropertyOne", c => c.Int(nullable: false));
AddColumn("dbo.SomeModel", "PropertyTwo", c => c.Int(nullable: false));
}
The target database contains columns PropertyOneand PropertyTwo, and the table __MigrationHistorycontains entries for the migration that created the table and the migration that added the columns.
When I run Add-Migrationto get some other changes, it also includes these two properties again:
public override void Up()
{
... other changes.
AddColumn("dbo.SomeModel", "PropertyOne", c => c.Int(nullable: false));
AddColumn("dbo.SomeModel", "PropertyTwo", c => c.Int(nullable: false));
}
What could be the reason for this? I also notice that if I revert all model changes and try Update-Database(which should not do anything), I get an error:
, . . DbMigrationsConfiguration.AutomaticMigrationsEnabled to true, .
?