question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Migration behavior changed between dotnet core 3.1 and dotnet 5

See original GitHub issue

Hi, I’m unsure if this is a breaking change or just a bug / also unsure if it’s related to Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime Npgsql.EntityFrameworkCore or Microsoft.EntityFrameworkCore

Repo with an example https://github.com/erwan-joly/EF5Bug

Before dotnet 3.1 the ef tools was not adding type and oldtype to altercolumn generated code. https://github.com/erwan-joly/EF5Bug/blob/master/EF31/Migrations/20210125041953_Second.cs#L10

on dotnet core 3.1 when using update-database First migration create Instant ADate as timestamp Second migration change it to Date ADate as date

on dotnet 5 First migration create Instant ADate as timestamp Second migration change it to Date ADate as timestamp

timestamp not being able to map to Date you then get runtime exception in EF5.

I’ve been able to fix this by manually adding the valid type/oldType to previous migrations(but modifying existing migration behavior seems like a bad practice). Also you don’t have this issue if you delete all migration and recreate with the recent ef tools as new tool nows add type / oldtype to altercolumn by default.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
bricelamcommented, Mar 9, 2021

We might be able to add some logic to SnapshotModelProcessor to handle this, but if the correct type simply isn’t available then there’s not much we can do, and users will need to manually update their old migrations.

1reaction
rojicommented, Feb 23, 2021

Wait, isn’t the expectation that migrations are (mostly always) forward compatible? Or is this 2.0 issue a ‘mostly always’ case?

Yes, and we do our best to always make it that way, but there are some occasion problems which it’s not always possible to fix without manual intervention. Having said that we definitely need to understand if this is something known.

@bricelam does any of this ring a bell? Probably better to start looking at #1600 (probable dup) which contains a bit more info. Have we seen issues with specifying oldType in scaffolded migration code?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migrate from ASP.NET Core 3.1 to 5.0
Run dotnet nuget locals --clear all to clear the NuGet package cache. Changes to Blazor app routing logic in 5.0.1 and further 5.x...
Read more >
Breaking changes in .NET 5
If you're migrating an app to .NET 5, the breaking changes listed here might affect you. Changes are grouped by technology area, such...
Read more >
Breaking changes in .NET Core 3.1
If you're migrating to version 3.1 of .NET Core or ASP.NET Core, the breaking changes listed in this article may affect your app....
Read more >
Breaking changes - .NET Framework to .NET Core
Breaking changes for migration from .NET ... NET Core versions 1.0 through 3.1, the breaking changes listed in this article may affect you....
Read more >
Behavior changes when comparing strings on .NET 5+
NET 5 introduces a runtime behavioral change where globalization APIs use ICU by default across all supported platforms.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found