Generate full SQL script from EF 5 Code First Migrations

How to use Entity Framework 5 First First Migrations to create a full script database from the initial (empty) state until the last migration?

Blog Post The MSDN Blog suggests doing this, but seems to be creating an empty script:

Update-Database -Script -SourceMigration: $InitialDatabase
+134
source share
3 answers

The API seems to have changed (or at least it doesn't work for me).

Running the following in the package manager console works as expected:

Update-Database -Script -SourceMigration:0
+269
source

, , , . Entity Framework:

Visual Studio :

Enable-Migrations

Add-Migration

, "Initial", . :

Update-Database

Update-Database -Script -SourceMigration:0

( , ).

+8

, , . .

# Powershell / Package manager console
Script-Migration

# Cli 
dotnet ef migrations script

-From -To, .

Script-Migration -From 20190101011200_Initial-Migration -To 20190101021200_Migration-2

https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/#generate-sql-scripts

.

, . , 0 ( ).

- , . .

. , . , , , , , .

+6

All Articles