Home > Software design >  All id changed to int8
All id changed to int8

Time:09-27

We updated our Software that we develop from .NetCore2.1 to .NET6.0. We also upgraded all the libraries like EF Core to the newest version.

What we found out now is, that if we migrate now, the migration want to change all the ID of our table to bigint (see example).

migrationBuilder.AlterColumn<long>(
    name: "Id",
    table: "Tokens",
    type: "bigint",
    nullable: false,
    oldClrType: typeof(long),
    oldType: "bigint")
    .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn)
    .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)

Do you know, why this is happening with the new EFCore6.0?

CodePudding user response:

This is happening because there was an intentional major change in version 3.1 of the Npgsql Entity Framework Core provider. You can see the change in the release notes and instructions on how to opt out of the change:

protected override void OnModelCreating(ModelBuilder modelBuilder)
    => modelBuilder.UseSerialColumns();
  • Related