我怎么能脚本一个Visual Studio数据库项目的部署?
我在Visual Studio中的DB项目,我想使用它,以便通过脚本部署在远程计算机上。我注意到,当我部署从Visual Studio,它生成一个.sql文件。
我截取该文件,并试图从与OSQL.EXE在命令行中运行它,但我没有任何成功。如果这项工作中,有没有更好的方法来从一个数据库项目编程部署数据库,可以通过引用的另一个项目,并调用一些方法来部署它?
解决方案 的MSBuild /目标:SQLBuild MyProjectName.dbproj
执行构建-只有行动。它建立只有命名MyProjectName.dbproj一个单一的数据库项目。在.dbproj文件中的项目属性用于组装构建脚本。
的MSBuild /目标:部署/属性:TargetDatabase = UpdatedTargetDatabase; TargetConnectionString =数据源=(本地)\ SQLEX $ P $干燥综合征;集成安全性= TRUE;池=假MyProjectName .dbproj
部署数据库项目,覆盖目标数据库名称和连接字符串。
How can I script the deployment of a Visual Studio database project?
I have a DB project in visual studio and I would like to use it in order to deploy on remote machines via a script. I notice that when I 'deploy' from visual studio, it generates a .sql file.
I intercepted this file and tried running it from the command line with osql.exe, but I didn't have any success. Should this work, is there a better way to deploy a database programatically from a database project, may be by referencing in another project and calling some method to deploy it?
解决方案MSBuild /target:SQLBuild MyProjectName.dbproj
Performs a build-only action. It builds only a single database project named MyProjectName.dbproj. The project properties within the .dbproj file are used to assemble the build script.
MSBuild /target:Deploy /property:TargetDatabase=UpdatedTargetDatabase;TargetConnectionString="Data Source=(local)\SQLEXPRESS;Integrated Security=True;Pooling=False" MyProjectName.dbproj
Deploys the database project, overriding the target database name and connection string.