You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to update the database, this following error appears:
System.NullReferenceException: Object reference not set to an instance of an object.
at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlSqlGenerationHelper.RequiresQuoting(String identifier)
at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlSqlGenerationHelper.DelimitIdentifier(String identifier)
at Npgsql.EntityFrameworkCore.PostgreSQL.Migrations.NpgsqlMigrationsSqlGenerator.<>c__DisplayClass4_0.<Generate>g__AddSequenceBumpingForSeeding|0()
at Npgsql.EntityFrameworkCore.PostgreSQL.Migrations.NpgsqlMigrationsSqlGenerator.Generate(IReadOnlyList`1 operations, IModel model, MigrationsSqlGenerationOptions options)
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.GenerateUpSql(Migration migration, MigrationsSqlGenerationOptions options)
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.<>c__DisplayClass16_2.<GetMigrationCommandLists>b__2()
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String connectionString, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String connectionString, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Object reference not set to an instance of an object.
migrationBuilder.Sql("INSERT INTO \"Entity\"(\"Id\") VALUES('{939b75ce-c3b4-4b94-9382-27cd4c5093fa}')");migrationBuilder.Sql("INSERT INTO \"Entity\"(\"Id\") VALUES('{ed7bed81-207a-436a-9798-24b9f1a79e34}')");
everything is working great.
The text was updated successfully, but these errors were encountered:
@antoineatrhea are you able to submit a minimal project that shows this happening? A simple model for the above entity types, along with their seed data, should be sufficient.
Thanks, the missing piece was the TPT hierarchy - the post-seeding sequence bumping logic was going over the properties of all entities mapped to the table, and assuming that those properties are mapped to columns of the table; this included children properties which are in a separate table in TPT, and so aren't mapped to columns in the base table. Will fix.
roji
added a commit
to roji/efcore.pg
that referenced
this issue
Sep 9, 2022
roji
changed the title
Update-Database causes NullReferenceException
Can't generate migration which does seeding with TPT and identity/sequence generation
Sep 9, 2022
A migration provides the following generated method :
When trying to update the database, this following error appears:
If we replace the generated
by
everything is working great.
The text was updated successfully, but these errors were encountered: