We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Entity Framework 6.2.0 Npgsql 4.0.2 EntityFramework6.Npgsql 3.2.0
Adding integer field/column to table that currently have records in it causes error on automatic migrations:
'23502: column "xxxx" contains null values'
The executed SQL command is:
ALTER TABLE "xxx"."yyy" ADD "zzz" int4 NOT NULL
The same migration works in SQL Server and MySQL with no issues, setting the field in existing rows with type default value.
I think that a default value should be set for non-nullable columns when migrating, which must be the default value for type, in this case 0.
0
The SQL statement should be:
ALTER TABLE "xxx"."yyy" ADD "zzz" int4 NOT NULL DEFAULT 0
P.S: Annotating entity field with [DefaultValue(0)] does not change anything.
[DefaultValue(0)]
P.P.S: The solution - in NpgsqlMigrationSqlGenerator, line 577, the following should be added:
NpgsqlMigrationSqlGenerator
else if (!(column.IsNullable ?? false) && column.ClrDefaultValue != null) { sql.Append(" DEFAULT "); AppendValue(column.ClrDefaultValue, sql); }
The text was updated successfully, but these errors were encountered:
My last version of this:
else if (column.IsNullable != null && !column.IsNullable.Value && column.ClrDefaultValue != null) { sql.Append(" DEFAULT "); AppendValue(column.ClrDefaultValue, sql); }
On the 6.4.1 release, this must be added between line 553 and line 554 of the NpgsqlMigrationSqlGenerator.cs file.
Is it so hard to add it in code? 2 years have passed. I am using my own local branch solely for this.
Sorry, something went wrong.
No branches or pull requests
Entity Framework 6.2.0
Npgsql 4.0.2
EntityFramework6.Npgsql 3.2.0
Adding integer field/column to table that currently have records in it causes error on automatic migrations:
The executed SQL command is:
The same migration works in SQL Server and MySQL with no issues, setting the field in existing rows with type default value.
I think that a default value should be set for non-nullable columns when migrating, which must be the default value for type, in this case
0
.The SQL statement should be:
P.S: Annotating entity field with
[DefaultValue(0)]
does not change anything.P.P.S:
The solution - in
NpgsqlMigrationSqlGenerator
, line 577, the following should be added:The text was updated successfully, but these errors were encountered: