-
Notifications
You must be signed in to change notification settings - Fork 256
Closed
Copy link
Milestone
Description
A migration provides the following generated method :
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "AspNetRoles",
keyColumn: "Id",
keyValue: "AF8956F8-CA85-4DF2-8CB6-C46D0845B987",
column: "ConcurrencyStamp",
value: "e718543c-b540-465c-99da-b12c1276826b");
migrationBuilder.UpdateData(
table: "AspNetUsers",
keyColumn: "Id",
keyValue: "F3E3BACF-5F7C-4657-88E9-FA904EFB64D7",
columns: new[] { "ConcurrencyStamp", "PasswordHash", "SecurityStamp" },
values: new object[] { "dc0b5b80-6508-4638-a5ff-60cbb0f5f342", "AQAAAAEAACcQAAAAEIRpol47PPunZ80z2nNoHH04oontoJEqfpkJFVDBcv8D0Hrm78+uJh/w4+3AFGfPSg==", "b6c8f81a-bf91-4edb-9cff-71c45a61a94d" });
migrationBuilder.InsertData(
table: "Entity",
column: "Id",
values: new object[]
{
new Guid("939b75ce-c3b4-4b94-9382-27cd4c5093fa"),
new Guid("ed7bed81-207a-436a-9798-24b9f1a79e34")
});
migrationBuilder.InsertData(
table: "Project",
columns: new[] { "Id", "EntityContainerId", "ProjectName" },
values: new object[] { new Guid("ed7bed81-207a-436a-9798-24b9f1a79e34"), null, "Test Project" });
migrationBuilder.InsertData(
table: "Participant",
columns: new[] { "Id", "EntityContainerId", "RoleId", "UserId" },
values: new object[] { new Guid("939b75ce-c3b4-4b94-9382-27cd4c5093fa"), new Guid("ed7bed81-207a-436a-9798-24b9f1a79e34"), new Guid("fd580a55-9666-4abe-a02b-3a99478996f7"), new Guid("3503bf4c-1211-41eb-b369-aaa6bbdf5ff8") });
}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.
If we replace the generated
migrationBuilder.InsertData(
table: "Entity",
column: "Id",
values: new object[]
{
new Guid("939b75ce-c3b4-4b94-9382-27cd4c5093fa"),
new Guid("ed7bed81-207a-436a-9798-24b9f1a79e34")
});by
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.