Migrations: Write script to .sql file (Fixes #420)

This is more-or-less the same logic we used in EF6.
Doh, thanks. (I'm in the process of creating a VM to actually test this code.)