ColumnBase.FormatNullable has the following:
if (column.IsNullable.HasValue && column.IsNullable.Value) {
return string.Empty;
}
This might seem to be a reasonable default, but if the type of the column is a SQL Server user defined type with a default of NOT NULL, the net result is that the column gets created with NOT NULL, since the emitted DDL doesn't specify it.
For example, we make heavy use of this custom type:
exec sp_addtype instanceid, 'bigint', 'NOT NULL'
If I then do
Create.Table("filecartItem")
//more columns
.WithColumn("fileattachment_id").AsCustom("instanceid").Nullable();
the DDL will look like:
CREATE TABLE [dbo].[filecartitem] (
//other columns
[fileattachment_id] instanceid
))
and the resulting filecart_id column will end up with the default "NOT NULL" 'inherited' for type instanceid.
I think the code should omit the NULL / NOT NULL only if the migrator did not specify it.
ColumnBase.FormatNullable has the following:
This might seem to be a reasonable default, but if the type of the column is a SQL Server user defined type with a default of NOT NULL, the net result is that the column gets created with NOT NULL, since the emitted DDL doesn't specify it.
For example, we make heavy use of this custom type:
exec sp_addtype instanceid, 'bigint', 'NOT NULL'If I then do
the DDL will look like:
and the resulting filecart_id column will end up with the default "NOT NULL" 'inherited' for type instanceid.
I think the code should omit the NULL / NOT NULL only if the migrator did not specify it.