Change logical and physical file name when deploying dacpac

1.3k views Asked by At

When deploying a dacpac for the first time using SqlPackage.exe how do I control the logical and physical file names for the new database.

The standard SQL statement would be:

CREATE DATABASE Bar
ON PRIMARY (NAME = 'Foo', FILENAME = '...\Foo\Foo.mdf')
LOG ON (NAME = 'Foo_log', FILENAME = '...\Foo\Foo.ldf')
1

There are 1 answers

0
Chris Chilvers On

It seems this is not possible out of the box with the current tools. The variables $(DefaultFilePath) and $(DefaultLogPath) control the location but cannot be changed from the command line.

These values can be changed by using a custom deployment contributor, see Overriding DefaultDataPath and DefaultLogPath variables when using SqlPackage to publishing a dacpac.