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
Migrations: Provide easy way to get script from latest applied on database to latest in the codebase #15762
This is what Update-Database -Script does by default in EF6 and it feels very natural, but in EF Core, that isn't available, so you need to run other commands to find out what the latest migration applied is before you can pass that to Script-Migration -From argument.
See Twitter thread about this:
Migrations in EF Core are a pain in the ass.
* Nearly impossible to tell which connection string your getting * Several issues with model changes not showing up (had to blow away and start over). * Command Line tooling not working.
But it sure would be nice to have that as something you don't have to remember like a --pending flag. I would even argue that this should be the default. The 90% use case is that you want to apply pending changes to the database.
Actually come to think of this I think this behavior would be better provided with update-database --script just as it did in EF6. Script-Migration isn't obviously tied to a DB Operation so it's kind of out of scope. But update-database --script makes good sense IMHO and you have to be generating the script to update the database anyway. Not only does that provide the script it also lets you preview the actual changes that are being made - currently update-database feels just like a complete black box.
Reacted by Joe Park, Devvox93, Glen and Dale Cameron
I'm very eager to use such functionality, as I'm sure many others with me.
The 7.0.0 milestone is closed, but this issue is still open.
Any news? Related issues/PRs with more progress maybe? I've been looking around with references, but am unsure which is "the" place to measure progress.
@bricelam You seem to have been involved in many of these issues/PRs. Could you shed a light on the status?
I believe this has been made possible with #22109, right?
But this issue is about making it easier with a new command option.
@Devvox93 Unfortunately, this did not make it into EF7. As of now, the issue is in the Backlog milestone. This means that it is not planned for the next release (EF Core 8.0). We will re-assess the backlog following the this release and consider this item at that time. However, keep in mind that there are many other high priority features with which it will be competing for resources. Make sure to vote (👍) for this issue if it is important to you. Right now this issue has only one vote, which makes it very low priority compared to many other issues.
@ajcvickers Thanks for the update and clarification. Seeing the number of votes, perhaps this issue will even be unnecessary.
Then, however, it'd be nice if some of the script examples Brice has put here and there could be added to the documentation of, for example, Get-Migration or Script-Migration.
Since I'm currently working with this, I'll add some examples to the docs through a PR when I'm done.
Quite unbelievable that this issue only had 2 votes. I just want to output the SQL for unapplied migrations, for review purposes. Using scripts is the recommended method of deployment, yet it's not possible to simply view the pending SQL.
Activity
bricelam commentedon May 20, 2019
I think we have a few open PRs (and/or items on the backlog) that would enable you to do something like this:
RickStrahl commentedon May 20, 2019
Thanks for that @bricelam - that's helpful!
But it sure would be nice to have that as something you don't have to remember like a
--pendingflag. I would even argue that this should be the default. The 90% use case is that you want to apply pending changes to the database.Actually come to think of this I think this behavior would be better provided with
update-database --scriptjust as it did in EF6.Script-Migrationisn't obviously tied to a DB Operation so it's kind of out of scope. Butupdate-database --scriptmakes good sense IMHO and you have to be generating the script to update the database anyway. Not only does that provide the script it also lets you preview the actual changes that are being made - currentlyupdate-databasefeels just like a complete black box.Devvox93 commentedon Feb 8, 2023
I'm very eager to use such functionality, as I'm sure many others with me.
The 7.0.0 milestone is closed, but this issue is still open.
Any news? Related issues/PRs with more progress maybe? I've been looking around with references, but am unsure which is "the" place to measure progress.
@bricelam You seem to have been involved in many of these issues/PRs. Could you shed a light on the status?
I believe this has been made possible with #22109, right?
But this issue is about making it easier with a new command option.
ajcvickers commentedon Feb 8, 2023
@Devvox93 Unfortunately, this did not make it into EF7. As of now, the issue is in the Backlog milestone. This means that it is not planned for the next release (EF Core 8.0). We will re-assess the backlog following the this release and consider this item at that time. However, keep in mind that there are many other high priority features with which it will be competing for resources. Make sure to vote (👍) for this issue if it is important to you. Right now this issue has only one vote, which makes it very low priority compared to many other issues.
Devvox93 commentedon Feb 9, 2023
@ajcvickers Thanks for the update and clarification. Seeing the number of votes, perhaps this issue will even be unnecessary.
Then, however, it'd be nice if some of the script examples Brice has put here and there could be added to the documentation of, for example, Get-Migration or Script-Migration.
Since I'm currently working with this, I'll add some examples to the docs through a PR when I'm done.
glen-84 commentedon Sep 15, 2023
Quite unbelievable that this issue only had 2 votes. I just want to output the SQL for unapplied migrations, for review purposes. Using scripts is the recommended method of deployment, yet it's not possible to simply view the pending SQL.
glen-84 commentedon Sep 15, 2023
It's not even possible to generate the script for a single migration without providing the name of the previous migration. 😞
(confusion)