gpt4 book ai didi

.net - 在 VS2010 数据库项目中部署时设置 DefaultDataPath 和 DefaultLogPath

转载 作者:行者123 更新时间:2023-12-04 05:50:44 24 4
gpt4 key购买 nike

确实,以下查询最初不是我的,但我在工作中面临着确切的问题。从而照原样复制问题陈述。我找不到任何解决方案。我非常感谢以下问题集的任何建议或亮点:

I do not have any hardcoding in Schema Objects\Database Level Objects\Storage\Files - both in database and log files.

The deployment script that gets generated when I click "deploy" from db project has hardcoding in :SETVAR with database and log file path assigned to $(DefaultDataPath) and $(DefaultLogPath) - see below: :setvar DefaultDataPath "C:\DB\Microsoft SQL Server\MSSQL10_50.MITCHELL\MSSQL\DATA\" :setvar DefaultLogPath "C:\DB\Microsoft SQL Server\MSSQL10_50.MITCHELL\MSSQL\DATA\".

I want the deployment script to accept input for data and log path. But based on script that is being currently generated, I'll have to manually comment the above 2 lines and modifiy the CREATE DATABASE statement as shown below every single time to replace any reference to "DefaultDataPath" and "DefaultLogPath" with "InputDefaultDataPath" and "InputDefaultLogPath" CREATE DATABASE [$(DatabaseName)] ON PRIMARY(NAME = [TEST_DB], FILENAME = '$(InputDefaultDataPath)$(DatabaseName).mdf', >SIZE = 3072 KB, FILEGROWTH = 1024 KB) LOG ON (NAME = [TEST_DB_log], FILENAME = >'$(InputDefaultLogPath)$(DatabaseName)_log.ldf', SIZE = 1024 KB, MAXSIZE = 2097152 MB, FILEGROWTH = 10 %) COLLATE SQL_Latin1_General_CP1_CI_AS

 Question 1: How do I prevent db project from scripting the below two lines and also 

prevent it from subsituting these variables in CREATE DATABASE statement? :setvar DefaultDataPath "C:\DB\Microsoft SQL Server\MSSQL10_50.MITCHELL\MSSQL\DATA\" :setvar DefaultLogPath "C:\DB\Microsoft SQL Server\MSSQL10_50.MITCHELL\MSSQL\DATA\".

Question 2: How do I make db project to automaticaly script deployment script in such a way that it accepts user input for DefaultDataPath and DefaultLogPath without me manually changing it to include $(InputDefaultDataPath) and $(InputDefaultLogPath) variable?

最佳答案

在 Visual Studio 2010 中,有一个名为“CommentOutSetVarDeclarations”的项目设置。如果您选中此选项,您提到的两个默认 SETVAR 行将被注释掉。

这使您可以在从 SQLCMD 运行部署脚本时从命令行提供 $(DefaultDataPath) 和 $(DefaultLogPath) 的值。

关于.net - 在 VS2010 数据库项目中部署时设置 DefaultDataPath 和 DefaultLogPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10085124/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com