|
| 1 | +--- |
| 2 | +title: SQL Projects System Objects |
| 3 | +description: Learn about referencing system objects in SQL projects. |
| 4 | +author: dzsquared |
| 5 | +ms.author: drskwier |
| 6 | +ms.reviewer: maghan, randolphwest |
| 7 | +ms.date: 10/10/2025 |
| 8 | +ms.service: sql |
| 9 | +ms.subservice: sql-database-projects |
| 10 | +ms.topic: concept-article |
| 11 | +ms.collection: |
| 12 | + - data-tools |
| 13 | +--- |
| 14 | + |
| 15 | +# SQL projects system objects |
| 16 | + |
| 17 | +[!INCLUDE [SQL Server Azure SQL Database Azure SQL Managed Instance FabricSQLDB](../../../includes/applies-to-version/sql-asdb-asdbmi-fabricsqldb.md)] |
| 18 | + |
| 19 | +SQL projects validate database object references during the project build process. By default, SQL projects don't include system objects in the database model, which can lead to validation errors if your project contains references to system objects. To resolve these validation errors, you would include a database reference to the `master.dacpac` for the target platform of your project. |
| 20 | + |
| 21 | +The `master.dacpac` database reference can be added as a [package reference](package-references.md) in Microsoft.Build.Sql SDK-style SQL projects or as an [artifact reference](database-references.md) in both SDK-style and original SQL projects. |
| 22 | + |
| 23 | +## Add a package reference |
| 24 | + |
| 25 | +The available system database packages are: |
| 26 | + |
| 27 | +- [SQL Server `master` system database](https://www.nuget.org/packages/Microsoft.SqlServer.Dacpacs.Master) |
| 28 | +- [SQL Server `msdb` system database](https://www.nuget.org/packages/Microsoft.SqlServer.Dacpacs.Msdb) |
| 29 | +- [Azure SQL Database `master` system database](https://www.nuget.org/packages/Microsoft.SqlServer.Dacpacs.Azure.Master) |
| 30 | +- [SQL database in Fabric system objects](https://www.nuget.org/packages/Microsoft.SqlServer.Dacpacs.DbFabric) |
| 31 | +- [Azure Synapse Analytics `master` system database](https://www.nuget.org/packages/Microsoft.SqlServer.Dacpacs.Synapse.Master) |
| 32 | +- [Azure Synapse Analytics serverless pools `master` system database](https://www.nuget.org/packages/Microsoft.SqlServer.Dacpacs.SynapseServerless.Master) |
| 33 | + |
| 34 | +The most direct method for adding a package reference to a SQL project is to use the .NET command-line interface (CLI). The following example adds a package reference to the Azure SQL Database `master` system database to a SQL project: |
| 35 | + |
| 36 | +```bash |
| 37 | +dotnet add <path-to-sqlproj> package Microsoft.SqlServer.Dacpacs.Azure.Master |
| 38 | +``` |
| 39 | + |
| 40 | +This command adds the following entry to the `.sqlproj` file (the package version will reflect the latest version available at the time the command is run): |
| 41 | + |
| 42 | +```xml |
| 43 | +... |
| 44 | + <ItemGroup> |
| 45 | + <PackageReference Include="Microsoft.SqlServer.Dacpacs.Azure.Master" Version="170.0.1" /> |
| 46 | + </ItemGroup> |
| 47 | +</Project> |
| 48 | +``` |
| 49 | + |
| 50 | +## Add an artifact reference |
| 51 | + |
| 52 | +The VS Code and Visual Studio SQL project interfaces provide a method for adding an artifact reference to the `master.dacpac` file for the target platform of your project. |
| 53 | + |
| 54 | +The resulting edits to the `.sqlproj` file will look similar to the following example, which adds an artifact reference to the Azure SQL Database `master` system database in Visual Studio: |
| 55 | + |
| 56 | +```xml |
| 57 | +<ItemGroup> |
| 58 | + <ArtifactReference Include="$(DacPacRootPath)\Extensions\Microsoft\SQLDB\Extensions\SqlServer\AzureV12\SqlSchemas\master.dacpac"> |
| 59 | + <HintPath>$(DacPacRootPath)\Extensions\Microsoft\SQLDB\Extensions\SqlServer\AzureV12\SqlSchemas\master.dacpac</HintPath> |
| 60 | + <SuppressMissingDependenciesErrors>False</SuppressMissingDependenciesErrors> |
| 61 | + <DatabaseVariableLiteralValue>master</DatabaseVariableLiteralValue> |
| 62 | + </ArtifactReference> |
| 63 | + </ItemGroup> |
| 64 | +``` |
| 65 | + |
| 66 | +The `master.dacpac` files are referenced from the installation location of the applications, which can be fragile for some CI/CD systems. You can copy the `master.dacpac` file to a location within your solution and update the `Include` and `HintPath` attributes to point to that location if your build system doesn't include the system database files. |
| 67 | + |
| 68 | +## SQL database in Fabric |
| 69 | + |
| 70 | +The SQL database in Fabric system objects are included in the `Microsoft.SqlServer.Dacpacs.DbFabric` package, but additional steps might be required to configure the database reference correctly for the SQL database in Fabric environment. |
| 71 | + |
| 72 | +The SQL project created with the integrated source control in Fabric includes the package reference and the `DatabaseVariableLiteralValue` property set to `master`. This property is required because SQL database in Fabric doesn't provide access to the `master` database but the same system objects can be referenced in the user database. |
| 73 | + |
| 74 | +If you create a new SQL project in Visual Studio or VS Code, you must update the `DatabaseVariableLiteralValue` property to `master` to match the database name used in the SQL database in Fabric environment. |
| 75 | + |
| 76 | +```xml |
| 77 | + <ItemGroup> |
| 78 | + <PackageReference Include="Microsoft.SqlServer.Dacpacs.DbFabric"> |
| 79 | + <SuppressMissingDependenciesErrors>False</SuppressMissingDependenciesErrors> |
| 80 | + <DatabaseVariableLiteralValue>master</DatabaseVariableLiteralValue> |
| 81 | + <Version>170.0.0</Version> |
| 82 | + </PackageReference> |
| 83 | + </ItemGroup> |
| 84 | +``` |
| 85 | + |
| 86 | +## Related content |
| 87 | + |
| 88 | +- [Database references overview](database-references.md) |
| 89 | +- [SQL projects package references](package-references.md) |
| 90 | +- [SqlPackage CLI](../../sqlpackage/sqlpackage.md) |
0 commit comments