Include temporal tables in migration script
Right now, the migration code and the migration SQL scripts look the same as if temporal tables were not being used. The ITemporalTableSqlBuilder interface has to be used in order to preview the exact SQL script or to execute that script manually. It would be useful if the EF migration files included the temporal columns and flags so that the changes can be previewed or modified.
I can't seem to find a solution how to plug a custom SQL script in the migrations themselves.
The only solution I find is creating a custom migrations operations (https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/operations) where you create an extension method over MigrationBuilder and have it generate your custom SQL code but then you have to manually call the extension method in your migration. I haven't tested if you call Script-Migration whether the custom SQL will show up but even if it does, one can always forget to call the extension method and we are back to basics.
If you or someone else have an idea or appropriate solution, I would be happy to take a look at it.
I have attempted to include temporal-metadata into the migrations myself, and it is much more complicated than I initially expected. My approach was similar to the one you took by extending the SqlServerMigrationsGenerator for #4. My prototype also extended the CreateTableOperation to try and include the SysStartTime and SysEndTime properties in the initial table rather than tacking them on at the end. While such extensions would be nice, I've come to the conclusion that full support for temporal tables is best left for the official SQL Server provider. That feature is being tracked by dotnet/efcore#4693.
Due to this it's not possible to generate SQL scripts using
dotnet ef migrations script