O'Reilly logo

Code-First Development with Entity Framework by Sergey Barskiy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Applying migrations

So far, we applied all migrations using Visual Studio. This works really well when developers are working on features inside Visual Studio. However, when it comes to updating, testing, or production environments, this approach does not really work.

In order to update such software installations, we are given more options, which are as follows:

  • Generate the changes script
  • Use migrate.exe
  • Use the migrating initializer

Applying migrations via a script

We can easily generate a script by running the Update-Database commandlet with the Script parameter inside the same Package Manager Console window, using the following code line:

Update-Database -Script

As soon as this commandlet completes, the generated script will be opened. It will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required