Karan
Karan

Reputation: 15104

EF Migrations on CI Build Server

I run the migrations within Visual Studio's package manager. I am currently on the process of setting up a CI for our project. I was wondering how can you update the database from the CI (since you are not in the Visual Studio environment). Do I need to find a powershell.exe and execute that?

Ps. I am using Teamcity for CI.

Upvotes: 7

Views: 1623

Answers (1)

bricelam
bricelam

Reputation: 30385

You can use migrate.exe to migrate a database outside of the Visual Studio environment. It is located in the packages/EntityFramework.x.x.x/tools folder.

The tool has some rough edges that you'll need to be aware of.

  • Make sure EntityFramework.dll and migrate.exe are in the same directory
  • You'll probably need to specify the startUpDirectory parameter. Point it to the output directory of your application.

You can also write your own tools, the Update-Database command is backed by the Update method on DbMigrator.

Upvotes: 7

Related Questions