从Team City运行更新数据库

moo*_*rol 19 asp.net teamcity entity-framework-4.3

我使用Entity Framework 4.3数据库迁移创建了一个新的应用程序.使用"update-database"命令从包管理器控制台中进行迁移可以很好地工作.

现在我想在每次使用Team City构建应用程序时运行数据库迁移,看起来我需要创建一个执行此操作的powershell脚本.

任何人都可以指点我如何从命令行或powershell运行包管理器命令?我所能找到的是有关如何通过包管理器控制台执行此操作的说明,我不知道如何从Team City构建步骤运行.

moo*_*rol 19

migrate.exe是我正在寻找的,它可以在"packages\EntityFramework.4.3.1\tools"中找到.

使用以下方法在Team City中添加新的构建步骤:

运行者类型:命令行

命令可执行文件:packages\EntityFramework.4.3.1\tools\migrate.exe

命令参数:MyApplicationName/StartupDirectory:MyApplicationName\bin


ang*_*sen 6

将Entity Framework nuget安装到repo并使用packages\EntityFramework.5.0.0\tools \下的随附migrate.exe或等效项.

然后像这样运行批处理脚本:

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
Run Code Online (Sandbox Code Playgroud)

我回答了类似的问题,在那里我解释了为什么我还没有指定web/app.config文件.