I'm adding a int property called Order to an existing entity that already has records in the DB tables.
public class Page : Content
{
// ...
public int Order { get; set; }
// ...
}
However, when I run "update-database", it's adding the column as nullable with a default value of null. I tried using [DefaultValue(0)], as well as setting the default in the constructor. Neither work.
How can I add a column/property to an existing set of data and have it populate as a non-null value of 0? Thanks.
That's because of inheritance. Not all properties in derived types can be defined as not-nullable, because types in the upper level of hierarchy doesn't have those properties.