I have this class:
public class HabitDo{
public int? HabitId { get; set; }
virtual public Habit Habit { get; set; }
public int DoId { get; set; }
virtual public Do Do { get; set; }
public string Restriction { get; set; }
public int? ObjectiveId { get; set; }
public Objective Objective { get; set; }
public virtual ICollection<DoObjective> Objectives { get; set; }
}
The table is just fine, but then I remove from code the Objective property:
public class HabitDo{
public int? HabitId { get; set; }
virtual public Habit Habit { get; set; }
public int DoId { get; set; }
virtual public Do Do { get; set; }
public string Restriction { get; set; }
public virtual ICollection<DoObjective> Objectives { get; set; }
}
And when calling update-database from the manager console EF renames the ObjectiveId column instead of dropping it:
EXECUTE sp_rename @objname = N'HabitDoes.ObjectiveId', @newname = N'Objective_Id', @objtype = N'COLUMN'
Any clues why this happens?