Reference Data Manager is installed in two parts: a Visual Studio extension and the essential build components. The extension allows you to create and edit database projects with reference data, whilst the essential build components are required to build and deploy those projects.
With the extension installed, you’ll have the option to Add New Reference Data File when right-clicking a table in the solution explorer. You can create a reference data file based on the contents of a CSV file, or create an empty reference data file and manually specify data using INSERT
statements.
When you build the project, Reference Data Manager uses the build components to incorporate any reference data files into the DACPAC, along with the other database objects.
A reference data file uses INSERT
statements to specify reference data for the table it depends upon. When you create a new reference data file (.refdata.sql) for a table in SSDT, Reference Data Manager updates the project file (.sqlproj) with a dependency to reflect this:
During deployment, Reference Data Manager compares the contents of the reference data file to the target table, and updates the target accordingly. Any rows that aren’t present in the reference data file will be deleted from the target table.
Reference Data Manager uses three components to process your reference data and add it to a DACPAC for deployment. These components are installed separately, and must be present in addition to the Visual Studio extension on the build machine:</span>
The build task takes the project file (.sqlproj) and looks for reference data files (.refdata.sql) and their corresponding table files. It produces a build catalog, containing a list of table filenames and their associated reference data filenames.
The build contributor takes the build catalog, produced by the build task, and replaces table filenames with table names. The result is a new deployment catalog file, for the deployment contributor. This removes any discrepancies between table filenames and table names.
The deployment contributor uses the deployment catalog to add reference data files to the DACPAC, along with the name of the table that the data belongs to.
During deployment, the deployment contributor adds INSERT
, UPDATE
and DELETE
statements to the deployment script, based on the differences between reference data in the source (the DACPAC) and the target database.
I produced this video as both an instructional resource for user testing, and as a way to attract more users to the tool. Including a common use case, I hoped to pique the interest of SSDT users experiencing pain when trying to import reference data.