1

Before applying a migration in EF Code First, you can ask to see the SQL script it intends to apply with:

PM> update-database -script

Unfortunately this opens a script named something like tmp939D.sql in Visual Studio and then freezes the IDE until it finishes generating the script. If the script is long, this is a long freeze. Is there some way to push this to a file on the hard drive instead of in the IDE? A way to specify the name of the SQL script file it generates?

Chris Moschini
  • 36,764
  • 19
  • 160
  • 190

1 Answers1

1

See this answer for a solution: https://stackoverflow.com/a/14339379/219187

This solution does NOT use -Script, but takes a C# approach. We implemented it in a unit test, so our build server generates the SQL scripts after every software change.

Community
  • 1
  • 1
theDmi
  • 17,546
  • 6
  • 71
  • 138