-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Renaming PeriodStart
and PeriodEnd
columns of a temporal table causes them to be swapped
#29902
Comments
I just double checked using the following SQL query select OBJECT_NAME(object_id) as table_name,* from sys.periods that the columns for |
migrations model differ is not aware of the period start/end annotations, and when figuring out renames it just looks at the names (and property mappings, but those are the same). It so happens that old names were in different order ("End", "Start") than the new ones ("From", "To"). Workaround is to rename one column at a time. |
Thanks for having looked into it. This is definitely not a satisfying workaround for such a task, but at the very least, it does the trick. |
Note for triage: root cause is tracked by #15178. We should consider raising the priority of this. |
Note from triage: at least try to fix this issue in 8.0, even if we don't get to all of #15178. |
…ral table causes them to be swapped Problem was that migration model differ was too lax with pairing up columns. Fix is to add more predicates - one that matches annotations+values and one that just matches annotations, ignoring the values, before we fallback to simple column definition. Now that we reworked temporal annotations, this actually gives clean match for the period start and period end column. Moreover, this change could improve matching in other, non-temporal scenarios. Fixes #29902
…ral table causes them to be swapped (#32328) Problem was that migration model differ was too lax with pairing up columns. Fix is to add more predicates - one that matches annotations+values and one that just matches annotations, ignoring the values, before we fallback to simple column definition. Now that we reworked temporal annotations, this actually gives clean match for the period start and period end column. Moreover, this change could improve matching in other, non-temporal scenarios. Fixes #29902
Hi,
I just discovered that, in my database, on 3 temporal tables, the meaning of the
PeriodStart
andPeriodEnd
column has been kind of swapped after renaming them (to be compliant with our naming convention).As a result, dates in the new
PeriodStart
-like column are greater than the dates in thePeriodEnd
one.Repro steps:
Having this entity model:
Having this in
DbContext
:Generates the following migration
Up()
:Then, if we are to rename the columns to be compliant with the
Con
prefix trigram, we add this to theDbContext
:And this is the resulting migration
Up()
generated method:Here, it seems to me that the renaming of the columns kind of "swaps" them, isn't it ?
Thanks.
Include provider and version information
EF Core version: 6.0.5
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 6.0
Operating system: Win 11
IDE: Visual Studio 2022 17.3.6
The text was updated successfully, but these errors were encountered: