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

This is more-or-less the same logic we used in EF6.
OK. If there's nowhere you can just output an error message then :shipit: