How do I customize the name of the shadow database

Hello 

I have following ShadowConnectionString

<ShadowConnectionString>Data Source=sqlserver-nprd-ted-dev2.database.windows.net;Initial Catalog=sqldb-nprd-ted-dev-$(username)_SHADOW;Pooling=False;Encrypt=False;Authentication=ActiveDirectoryIntegrated;Multi Subnet Failover=False</ShadowConnectionString>

unfortunately it is producing a DB called 

sqldb-nprd-ted-dev-$(username)_SHADOW

according to the documentation this should use the environment variable $USERNAME

https://documentation.red-gate.com/sca/developing-databases/concepts/shadow-database?_ga=2.182918694.123694452.1613014504-1216847519.1599029856

How do I use an environment variable in the ShadowConnectionString property of my user profile  ?
Tagged:

Answers

  • Kendra_LittleKendra_Little Posts: 139 Gold 3
    edited February 11, 2021 10:43AM
    Hi @pkettlew ,

    We looked into this, and I believe that we had phrased this in the documentation in a confusing way. 

    I think the following sentence was the source of the confusion:

    By default, the shadow database will be created on the same SQL Server Instance as the development database with the name [project]_$(username)_SHADOW.

    This was meant to explain the naming convention used behind the scenes and represent a placeholder for the user name, not to imply that you could use the variable when customizing the shadow database connection string. 

    I have updated the documentation page a bit to try to make how this works more clear. I changed the sentence quoted above to "[project]_[YourUserName]_SHADOW"  so that it doesn't resemble an environment variable. 

    I also reworded a little bit of info below there which may prove useful to you (the second bullet point is new-- we previously had that on a linked page and not here-- and the third is reworded for clarity).

    You can change where the shadow database is created by editing the user settings file for your project:

    • You may need to create the file if it doesn't exist, make sure it follows the naming convention: '<YourProjectName>.sqlproj.user'
    • This user file contains settings specific to your local environment which shouldn't be committed to version control – see our list of files to be excluded from version control
    • When using a database as a development source, you may choose to omit the "Initial Catalog" portion of the ShadowConnectionString. In this case the shadow database name will continue to be derived from the development database name and the shadow database will change if the development database is changed.
    I hope this helps, and thanks very much for bringing this to our attention.

    Kendra
Sign In or Register to comment.