liveBook · Manning

SQL script

As explained in Building Web APIs with ASP.NET Core

An SQL script is a file containing SQL statements that can be reviewed and executed to create or modify database structures or data.

An SQL script is a file containing SQL statements that can create or modify database structures or data. For the MyBGList production database, it provides a reviewable way to create the missing board-game tables. section 12.4.4

A deployment script offers practical advantages:

  • Generate it from the development machine with the dotnet-ef CLI, then execute it against the production database. section 12.4.4
  • Have an experienced DBA review and fine-tune the raw SQL for production requirements or to prevent accidental data loss. section 12.4.4
  • Use a dedicated SQL management tool, such as SSMS, because scripts are not self-contained executables. section 12.4.4

Generate the script

Run `dotnet ef migrations script -o ./Migrations/script.sql` on the development machine, review the resulting SQL, and execute it with a SQL management tool. section 12.4.4

> dotnet ef migrations script -o ./Migrations/script.sql

Inspect the concrete dotnet-ef command used to write a migration script to a file. section 12.4.4

How Building Web APIs with ASP.NET Core covers it

How deep it goes
Explains generation, DBA review, and tool-based execution, while deferring detailed SQL commands and alternative implementation mechanics.
Examples
Uses the dotnet-ef migration-script command and SSMS as the concrete generation and execution workflow.
What it assumes
Assumes a development database and EF Core migrations, while identifying production execution and review requirements.
What you can do after
Operate/configure production database deployment by generating, reviewing, and executing an EF Core SQL script.
How it connects
Connects SQL scripts with EF Core migrations, migration bundles, dotnet-ef, production deployment, and database management tools.

Also explained in

Compare how 2 books explain SQL script →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Web APIs with ASP.NET Core. The section links point to the parts of the book it draws on.