Configuring default values for initial size and auto-growth size for database when publishing dacpac (SSDT Database project)

Viewed 121

We use SSDT DB Projects to maintain and publish DB changes to SQL Server 2014 (and above). We're using DacFx API's in C# to publish dacpac files.

Is there any way we can configure in the dacpac the Initial Size and Autogrowth size for both Primary Data and Log files such that we can override the model database settings on target at the time of fresh database creation itself?

Or is Alter database script the only way to achieve it? If yes, what are the options available other than include it as part of the Post Deploy script?

Sample Alter script...

ALTER DATABASE DatabaseTest
MODIFY FILE (NAME = [SqlFile1], SIZE = 500MB, FILEGROWTH = 500MB);
1 Answers

You can avoid using a post deployment script by adding a FileGroup file item and specifying that you wish to Script file size in the advanced publish options.

ALTER DATABASE [$(DatabaseName)]
ADD FILE
(
    NAME = [SqlFile1],
    FILENAME = '$(DefaultDataPath)$(DefaultFilePrefix)_SqlFile1.ndf',
    SIZE = 500MB,
    MAXSIZE = UNLIMITED,
    FILEGROWTH = 500MB
) TO FILEGROUP [PRIMARY]

enter image description here

enter image description here

Check this answer here for more detail

Related