Database deploy (vsdbcmd.exe): DatabaseName and DefaultDataPath are ignored?

Based on your edit, perhaps this is helpful. https://blogs.msdn.com/gertd/Default.aspx?p=7

Adding variables

So far we have been looking at how things work, now it is time to add some new variables and put them to work. One place where variables come in handy is in the post deployment file that defines files: storage.sql. Variables will allow use to make the location environment dependent.

Inside the storage file you will find something like this:

IF NOT EXISTS(SELECT 1 FROM dbo.sysfiles WHERE name = 'fgdb_data') BEGIN ALTER DATABASE [$(databasename)] ADD FILE ( NAME = N'fgdb_data', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\fgdb_data.ndf', MAXSIZE = 100MB, FILEGROWTH = 10MB ) TO FILEGROUP [TABLES] END

We could parameterize this so the drive and directory get abstracted through a variable to:

:setvar drive "C:" :setvar directory "Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA"

IF NOT EXISTS(SELECT 1 FROM dbo.sysfiles WHERE name = 'fgdb_data') BEGIN ALTER DATABASE [$(databasename)] ADD FILE ( NAME = N'fgdb_data', FILENAME = N'$(drive)\$(directory)\fgdb_data.ndf', MAXSIZE = 100MB, FILEGROWTH = 10MB ) TO FILEGROUP [TABLES] END

Now that we have parameterized the script, next we want to make the variables part of the project file, so we have them defined in a single place instead of scattered around in the code at various places through :setvar statements.

Sorry I am just starting to learn the GDR myself but I'll need the answer to this to


This can be (is) caused when doing a Database Schema Synchronization -> Database Project. (My environment is VS2010 Enterprise RTM).

The generated ALTER DATABASE statements are generated to mirror the source database without taking any substitution values into account (it will also include initial database sizes, etc). The problem does not appear on an Initial Database Import.

Edit the files found under...

Schema Objects\Database Level Objects\Storage\Files

...and fix them to contain the correct $(DefaultDataPath)$(DatabaseName).mdf/$(DefaultLogPath)$(DatabaseName)_log.ldf values -- or other -- as appropriate. (Now mark them as "Skip" in your Schema Compare :-P)

With the above "correction" keeping the values external will once again work and is the preferred method of managing such properties.

Happy coding.