Skip to content

Instantly share code, notes, and snippets.

@ZacharyCouchman
Last active February 7, 2019 10:43
Show Gist options
  • Save ZacharyCouchman/9febfa3b2a9afa175303dcb260f355d7 to your computer and use it in GitHub Desktop.
Save ZacharyCouchman/9febfa3b2a9afa175303dcb260f355d7 to your computer and use it in GitHub Desktop.
Create EF Core database migrations as a single idempotent SQL script
// Paste this snippet in your .NET Core main .csproj file
// Change (or remove) the Condition statement if you want this to run on Debug builds (locally) as well
<Target Name="Create Migrations Script" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
<Exec Command="dotnet ef migrations script --configuration $(Configuration) --no-build --idempotent --output $(TargetDir)/migrations.sql"/>
</Target>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment