I have an int column which is currently mandatory
builder.Property(p => p.PropertyArea).IsRequired();
... but needs to be non-mandatory
builder.Property(p => p.PropertyArea)
But after applying Add-Migration migrationName, update-database etc there is no change to the column in sql server and it is still a not null column
Any idea why this might be the case?
Change type of PropertyArea to int?. As the docs state:
By convention, a property whose .NET type can contain null will be configured as optional, whereas properties whose .NET type cannot contain null will be configured as required. For example, all properties with .NET value types (int, decimal, bool, etc.) are configured as required, and all properties with nullable .NET value types (int?, decimal?, bool?, etc.) are configured as optional.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With