Case 01: The following generates a SQL script from a blank database to the latest migration.
In .Net Cli type the following.
dotnet ef migrations script
If you want to do the same in visual studio package manager console. Type the following
Script-Migration
Case 02: The following generates a SQL script from the given migration to the latest migration.
In .Net Cli
dotnet ef migrations script AddNewTables
In visual studio package manager console
Script-Migration AddNewTables
Case 03: The following generates a SQL script from the specified from migration to the specified to migration.
In .Net Cli
dotnet ef migrations script AddNewTables AddAuditTable
In visual studio package manager console
Script-Migration AddNewTables AddAuditTable
For more details. Please refer to the link.