I have created a new application using Entity Framework 4.3 database migrations. The migrations work great from the package manager console using the "update-database" command.
Now I want to run the database migrations every time the application is built using Team City, it looks like I need to create a powershell script that will do this.
Can anyone point me to some instructions on how to get the package manager commands to run from the command line, or powershell? All I can find is instructions on how to do this via the package manager console, which I don't know how to run from a Team City build step.
migrate.exe is what I was looking for, it is found in "packages\EntityFramework.4.3.1\tools".
Add a new build step in Team City using:
Runner type: command line
Command executable: packages\EntityFramework.4.3.1\tools\migrate.exe
Command parameters: MyApplicationName /StartupDirectory:MyApplicationName\bin
Install Entity Framework nuget to the repo and use the accompanying migrate.exe under packages\EntityFramework.5.0.0\tools\ or equivalent.
Then run a batch script like this:
SET AssemblyName=MyMvc4App
SET StartUpDirectory=MyMvc4App\bin\
SET ConnectionString=Server=tcp:XXXX.database.windows.net,1433;Database=XXXX;User ID=XXXX;Password=XXXX;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;MultipleActiveResultSets=True
SET ConnectionStringProvider=System.Data.SqlClient
SET ConfigFilePath=%CD%\MyMvc4App\web.config
SET MigrateExe=packages\EntityFramework.5.0.0\tools\migrate.exe
%MigrateExe% %AssemblyName%.dll /startUpDirectory:%StartUpDirectory% /startUpConfigurationFile:"%ConfigFilePath%" /connectionProviderName:"%ConnectionStringProvider%" /connectionString:"%ConnectionString%" /verbose
pause
I answered a similar question and there I explain why I have yet to get it working without specifying a web/app.config file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With