it:ad:code_first:migrations:howto:generate_sql_scripts

IT:AD:EF/CodeFirst/Migrations:HowTo:Generate SQL Scripts

Run the IT:AD:EF/CodeFirst/Migrations:HowTo:Update-Database command, but this time, adding the -script switch so that the changes are output as a sql script, rather than being applied.


We’ll also specify a source and target migration to generate the script for. We want a script to go from an empty database ($InitialDatabase) to the latest version (migration AddPostAbstract).

Update-Database -startupprojectname:App.AppHost.Web -projectname:App.Infrastructure -Script -SourceMigration: $InitialDatabase -TargetMigration: OurNamedMigration

Probably the most used scenario:

Update-Database -startupprojectname:App.AppHost.Web -projectname:App.Infrastructure -Script

Note:Omitting SourceMigration means Last Applied In Db, and omitting TargetMigration means Current Code Model.

## Notes ##

$InitialDatabase appears to be a keyword…

  • /home/skysigal/public_html/data/pages/it/ad/code_first/migrations/howto/generate_sql_scripts.txt
  • Last modified: 2023/11/04 02:19
  • by 127.0.0.1