You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
'ef migrations remove' uses designer files to walkback migrations #8880
changed the title [-]ef migrations remove uses designer files to walkback migrations[/-][+]'ef migrations remove' uses designer files to walkback migrations[/+]on Jun 16, 2017
@bricelam thanks for the suggestion. I can see that it should work fine if the issues are caught quickly. Unfortunately, this doesn't help much, since it still requires developers to:
be aware of the issue
check that there weren't any new migrations (even though there may not be any conflicts) before merging their PRs
regenerate and re-validate their existing migration
Not to mention the mess this can cause downstream if the issues are not caught right away. Trying to sort through designer files to identify the source of the issues can be quite time consuming.
Can you confirm that the designer file is not used when generating migrations? And that it will only become a problem when trying to roll them back?
Can you confirm that the designer file is not used when generating migrations? And that it will only become a problem when trying to roll them back?
Correct. The model snapshot is used to generate new migrations, and it will get merged properly like any other version controlled file.
The issue here is we need to synthesize the previous model snapshot which gets messy if you've merge new migrations into the mix.
As part of using Migrations, I think developers need to be very aware of when they merge new migrations into a branch. Being able to detect when a merge occurred (issue #1911) would go a long way to prevent errors that may otherwise go undetected. Heck, with that a dotnet ef migrations rebase command could even be made to simplify the process.
That makes sense, but I think the solution is simpler than that. My expectation was that dotnet ef migrations remove would have used the last defined migration's (based on timestamp) Down method to rollback the model snapshot. I don't see the need to maintain incremental snapshots.
It's been a little while on this and I know you all are very busy but I was wondering if there was any update on the design. I would love to contribute if there is room. But moreover I think it would be beneficial if the design discussion was open to the community for input. If this is already the case, can you point me to where this is? I believe the decisions on this issue have greater impact than just fixing the described problem. I believe the problem at hand is a symptom of larger design issues. It will have a significant effect on the developer migration experience
I think we discussed this a bit further elsewhere (maybe on Twitter). The conclusions we came to were:
The snapshot is only used when automatically scaffolding a new migration. There should be nothing preventing teams from manually creating the migrations without a snapshot.
We could compute snapshots by applying the Up and Down operations to the model, but this feels very unnecessary and adds additional complexity to the pipeline, so it will likely never happen.
Closing as a duplicate of #1911 since we will consider this and other scenarios as part of that work.
Activity
[-]ef migrations remove uses designer files to walkback migrations[/-][+]'ef migrations remove' uses designer files to walkback migrations[/+]ajcvickers commentedon Jun 19, 2017
@bricelam to look into workarounds for 2.0. More complete fix will need to go on backlog.
bricelam commentedon Jun 19, 2017
This is another manifestation of the root cause of issue #996. Having #1911 would help us detect this situation and handle it better.
Workaround
In this situation, you should be able to use the following workflow.
20170616182356_modelC.csand20170616182356_modelC.Designer.csRemove-Migration(ordotnet ef migrations remove)modelBis usedAdd-Migrationto re-add the changes in the current branchjaredcnance commentedon Jun 20, 2017
@bricelam thanks for the suggestion. I can see that it should work fine if the issues are caught quickly. Unfortunately, this doesn't help much, since it still requires developers to:
Not to mention the mess this can cause downstream if the issues are not caught right away. Trying to sort through designer files to identify the source of the issues can be quite time consuming.
Can you confirm that the designer file is not used when generating migrations? And that it will only become a problem when trying to roll them back?
bricelam commentedon Jun 20, 2017
Correct. The model snapshot is used to generate new migrations, and it will get merged properly like any other version controlled file.
The issue here is we need to synthesize the previous model snapshot which gets messy if you've merge new migrations into the mix.
As part of using Migrations, I think developers need to be very aware of when they merge new migrations into a branch. Being able to detect when a merge occurred (issue #1911) would go a long way to prevent errors that may otherwise go undetected. Heck, with that a
dotnet ef migrations rebasecommand could even be made to simplify the process.jaredcnance commentedon Jun 20, 2017
That makes sense, but I think the solution is simpler than that. My expectation was that
dotnet ef migrations removewould have used the last defined migration's (based on timestamp)Downmethod to rollback the model snapshot. I don't see the need to maintain incremental snapshots.jaredcnance commentedon Sep 15, 2017
It's been a little while on this and I know you all are very busy but I was wondering if there was any update on the design. I would love to contribute if there is room. But moreover I think it would be beneficial if the design discussion was open to the community for input. If this is already the case, can you point me to where this is? I believe the decisions on this issue have greater impact than just fixing the described problem. I believe the problem at hand is a symptom of larger design issues. It will have a significant effect on the developer migration experience
5 remaining items
ajcvickers commentedon Sep 25, 2017
Moved this temporarily into 2.1 milestone so that @bricelam can write down some thoughts.
bricelam commentedon Jan 5, 2018
I think we discussed this a bit further elsewhere (maybe on Twitter). The conclusions we came to were:
UpandDownoperations to the model, but this feels very unnecessary and adds additional complexity to the pipeline, so it will likely never happen.Closing as a duplicate of #1911 since we will consider this and other scenarios as part of that work.