diff --git a/src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs b/src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs index 05fd67de0..eaeecd0bd 100644 --- a/src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs +++ b/src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs @@ -1601,6 +1601,21 @@ protected override void ColumnDefinition( } } + /// + protected override void DefaultValue( + object? defaultValue, + string? defaultValueSql, + string? columnType, + MigrationCommandListBuilder builder) + { + if (columnType is "jsonb" or "json" && defaultValue is "") + { + defaultValue = "{}"; + } + + base.DefaultValue(defaultValue, defaultValueSql, columnType, builder); + } + /// /// Checks for a annotation on the given column, and if found, assigns /// the appropriate SQL to .