Open
Description
When adding a non-nullable column to an existing table, a default value must be provided, otherwise the ALTER TABLE fails. We have various hard-coded hacks to deal with this scenario: MigrationsModelDiffer.GetDefaultValue() has specific handling for strings and arrays, and returns the default CLR value otherwise:
protected virtual object? GetDefaultValue(Type type)
=> type == typeof(string)
? string.Empty
: type.IsArray
? Array.CreateInstance(type.GetElementType()!, 0)
: type.UnwrapNullableType().GetDefaultValue();
This is wrong for reference types such as List<string>
and probably NetTopologySuite things as well.
We also have hacky differ code here, which specifically identifies CollectionToJsonStringConverter
to set []
for JSON columns.
I think we simply need a hook on our type mapping which provides this.