You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -42,6 +42,33 @@ The following example includes a package reference to the `Contoso.AdventureWork
42
42
</Project>
43
43
```
44
44
45
+
The following example includes a package reference to the `Contoso.AdventureWorks` package as a database reference for a different database (AdventureWorks) on the same server where the objects in the package become part of the database model in the SQL project:
In this example, the AdventureWorks `.dacpac` file is published as a package `Contoso.AdventureWorks` version `1.1.0` to a NuGet feed. The `<DatabaseSqlCmdVariable>` element specifies the name of the database on the same server where the objects in the package are located and would be used to indicate this reference in three-part naming. The [SQLCMD variable](sqlcmd-variables.md)`AdventureDB` is used to set the database name at deployment time and is used in the project similarly to this example query:
65
+
66
+
```sql
67
+
SELECT*FROM [$(AdventureDB)].dbo.Customers
68
+
```
69
+
70
+
The `<DacpacName>` element specifies the name of the `.dacpac` file for the package reference, without the file extension or path. The `<DacpacName>` element is optional and is only required when the name of the `.dacpac` file is different from the name of the package.
71
+
45
72
### System databases
46
73
47
74
The SQL system databases (`master`, `msdb`) are published on NuGet.org as database reference packages. These packages contain the schema for the system databases and can be used as package references in SQL projects. The system database packages are versioned to align with the version of SQL Server they're associated with. For example, the `master` system database package for SQL Server 2022 is `Microsoft.SqlServer.Dacpacs.Master` version `160.2.1` and can be added to a SQL project as a package reference:
@@ -82,7 +109,9 @@ Package metadata can be specified by properties inside the `<PropertyGroup>` ele
82
109
<Company>Contoso Outdoors</Company>
83
110
```
84
111
85
-
The `.nupkg` file created by the `dotnet pack` command can be published to a NuGet feed for use in SQL projects. This database objects can be viewed by anyone with access to the package, so consideration should be made for selecting a public or private feed location. For more information, see [Hosting with private package feeds](/nuget/hosting-packages/overview).
112
+
The `.nupkg` file created by the `dotnet pack` command can be published to a NuGet feed for use in SQL projects. These database objects can be viewed by anyone with access to the package, so consideration should be made for selecting a public or private feed location. For more information, see [Hosting with private package feeds](/nuget/hosting-packages/overview).
113
+
114
+
When referencing a package where the `PackageId` is different from the name of the `.dacpac` file, the `<DacpacName>` element is required in the package reference when consuming the package.
0 commit comments