Reputation: 1269
I migrate an ASP.NET Core project from 3.1 to 6.0.
I have copied old migration and pasted it to our new version
Migration on EF Core 3.1 (old)
migrationBuilder.AddColumn<DateTime>(
name: "CalendarStartDate",
table: "DealOverview",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
Migration in EF Core 6.0 (new)
migrationBuilder.AlterColumn<DateTime>(
name: "StartDate",
table: "DealOverview",
type: "timestamp without time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone");
The migration fails because this line
public DateTime StartDate { get; set; }
has changed.
I went from this package:
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.4" />
to this package:
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.1" />
Upvotes: 17
Views: 30504
Reputation: 141790
EF Core 6 Npgsql has introduced some breaking changes to timestamp handling logic. You can try to "revert" back to old behaviour by adding next line either to Startup
or Program
file:
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
But in general it is recommended to migrate to the new behaviour.
Upvotes: 31