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
A data-tier application (DAC) is a logical database entity that defines all of the [!INCLUDE [ssNoVersion](../../../../includes/ssnoversion-md.md)] objects - such as tables, views, and instance objects, including logins - associated with a user's database. A data-tier application is a self-contained unit of the entire database model and is portable in both `.dacpac` and `.bacpac` packages. [Tooling support](#data-tier-application-tools) for data-tier applications enable developers and database administrators to apply `.dacpac` and `.bacpac` files to new or existing databases or generate new files from existing databases.
32
+
A data-tier application (DAC) is a logical database entity that defines all of the [!INCLUDE [ssNoVersion](../../../../includes/ssnoversion-md.md)] objects - such as tables, views, and instance objects, including logins - associated with a user's database. A data-tier application is a self-contained unit of the entire database model and is portable in both `.dacpac` and `.bacpac` packages. [Tooling support](#data-tier-application-tools) for data-tier applications enables developers and database administrators to apply `.dacpac` and `.bacpac` files to new or existing databases or generate new files from existing databases.
33
33
34
34
## Operations
35
35
36
36
### BACPAC operations
37
37
38
38
The `.bacpac` file format is a related artifact that by default encapsulates the database schema and the data stored in the database. Objects in the `.bacpac` database model are limited to the surface area of Azure SQL Database. The primary use case for a `.bacpac` is to move a database from one server to another - or to [migrate a database from a local server to the cloud](/azure/azure-sql/database/migrate-to-database-from-sql-server) - and archiving an existing database in an open format.
39
39
40
-
-**Export** - the user can export a database to a `.bacpac` file. For more information, see [SqlPackage export](../../../sqlpackage/sqlpackage-export.md) and [Export a Database to a BACPAC File](export-bacpac-file.md).
41
-
-**Import** - the user can import a `.bacpac` file into a new database. For more information, see [SqlPackage import](../../../sqlpackage/sqlpackage-import.md) and [Import a BACPAC File to a Database](import-bacpac-file-create-new-database.md).
40
+
-**Export** - the user can export a database to a `.bacpac` file. For more information, see [SqlPackage export](../../../sqlpackage/sqlpackage-export.md) and [Export a BACPAC file](export-bacpac-file.md).
41
+
-**Import** - the user can import a `.bacpac` file into a new database. For more information, see [SqlPackage import](../../../sqlpackage/sqlpackage-import.md) and [Import a BACPAC file to create a new database](import-bacpac-file-create-new-database.md).
42
42
43
43
Learn more about database portability from the [SqlPackage portability documentation](../../../sqlpackage/sqlpackage.md#portability).
44
44
45
45
### DACPAC operations
46
46
47
-
The `.dacpac` data-tier application package is the build artifact from [SQL database projects](../../sql-database-projects.md)and can be used as part of a comprehensive database lifecycle management and DevOps strategy. Data isn't included in a `.dacpac` by default, but you can choose to include data from user tables when you extract a `.dacpac` from a live SQL Server or Azure SQL Database. As an integral part of the SQL database project workflow and database development lifecycle, `.dacpac` files are used in several operations. The primary operations are:
47
+
The `.dacpac` data-tier application package is the build artifact from [SQL database projects](../../sql-database-projects.md)You can use it as part of a comprehensive database lifecycle management and DevOps strategy. Data isn't included in a `.dacpac` by default, but you can choose to include data from user tables when you extract a `.dacpac` from a live SQL Server or Azure SQL Database. As an integral part of the SQL database project workflow and database development lifecycle, `.dacpac` files are used in several operations. The primary operations are:
48
48
49
-
-**Extract** - the user can extract a database into a `.dacpac`. For more information, see [SqlPackage extract](../../../sqlpackage/sqlpackage-extract.md) and [Extract a DAC From a Database](extract-dacpac-from-database.md).
50
-
-**Deploy**/**Publish** - the user can deploy a `.dacpac` to a host server. When the deployment is done to an existing database, the difference between the database and the DAC is dynamically calculated and applied as an incremental update. The term "publish" is often used interchangeably with "deploy." For more information, see [SqlPackage publish](../../../sqlpackage/sqlpackage-publish.md) and [Deploy a Data-tier Application](deploy-data-tier-application.md).
49
+
-**Extract** - extract a database into a `.dacpac`. For more information, see [SqlPackage extract](../../../sqlpackage/sqlpackage-extract.md) and [Extract a DACPAC from a database](extract-dacpac-from-database.md).
50
+
-**Deploy**/**Publish** - deploy a `.dacpac` to a host server. When you deploy to an existing database, the difference between the database and the DAC is dynamically calculated and applied as an incremental update. The term *publish* is often used interchangeably with *deploy*. For more information, see [SqlPackage publish](../../../sqlpackage/sqlpackage-publish.md) and [Deploy a data-tier application](deploy-data-tier-application.md).
51
51
52
-
These capabilities can be found in the SqlPackage CLI, SQL Server Management Studio, Azure Data Studio, and SQL Server Data Tools.
52
+
You can find these capabilities in the SqlPackage CLI, SQL Server Management Studio, Visual Studio Code, and SQL Server Data Tools.
53
53
54
54
In addition to publish and extract, you can also track the database model in the system metadata by utilizing the *dac registration* functionality:
55
55
56
-
-**Register** - the user can register a database as a data-tier application. Register stores a representation of the current state of the database schema in system metadata.
57
-
-**Unregister** - a database previously registered as a DAC can be unregistered.
58
-
-**Upgrade** - a database can be upgraded using a `.dacpac`.
56
+
-**Register** - register a database as a data-tier application. Register stores a representation of the current state of the database schema in system metadata.
57
+
-**Unregister** - unregister a database previously registered as a DAC.
58
+
-**Upgrade** - upgrade a database by using a `.dacpac`.
59
59
60
60
## Data-tier application tools
61
61
@@ -67,18 +67,17 @@ The following tools support the `.dacpac` and `.bacpac` formats:
-[SQL Server Management Studio](/ssms/sql-server-management-studio-ssms)
70
-
-[Azure Data Studio](/azure-data-studio/what-is-azure-data-studio)
71
70
72
-
In these tools, a database can be extracted to a `.dacpac` or exported to a `.bacpac`. Conversely, a `.bacpac`can be imported into a new database or a `.dacpac` can be published to a new or existing database.
71
+
In these tools, you can extract a database to a `.dacpac` or export it to a `.bacpac`. Conversely, you can import a `.bacpac` into a new database, or publish a `.dacpac` to a new or existing database.
73
72
74
73
### DACPAC and SQL projects
75
74
76
-
The following tools support the `.dacpac` file format in addition to providing editing of SQL database projects:
75
+
The following tools support the `.dacpac` file format and provide editing capabilities for SQL database projects:
77
76
78
-
-[SQL Server Data Tools in Visual Studio](../../../../ssdt/sql-server-data-tools.md)
In these tools, developers can design a database in an unconnected, client-side development environment. Learn more in the [SQL projects tools](../../sql-projects-tools.md) article.
80
+
Developers can use these tools to design a database in an unconnected, client-side development environment. For more information, see the [SQL projects tools](../../sql-projects-tools.md) article.
@@ -100,7 +100,7 @@ The script file is added to the project and opened in the query editor, where yo
100
100
101
101
::: zone pivot="sq1-visual-studio-code"
102
102
103
-
In the **Database Projects** view of Visual Studio Code or Azure Data Studio, right-click the project, and select **Add Pre-Deployment Script** or **Add Post-Deployment Script**. Provide a script name without the file extension.
103
+
In the **Database Projects** view of Visual Studio Code, right-click the project, and select **Add Pre-Deployment Script** or **Add Post-Deployment Script**. Provide a script name without the file extension.
104
104
105
105
The script file is added to the project and opened in the query editor, where you can complete the script. This script will be executed before or after the deployment plan is executed, every time the project is deployed.
-[SQL Database Projects extension](/azure-data-studio/extensions/sql-database-project-extension) or [SQL Database Projects extension for VS Code](https://marketplace.visualstudio.com/items?itemName=ms-mssql.sql-database-projects-vscode)
@@ -108,7 +108,7 @@ Select **Create** to create the project. The empty project is opened and visible
108
108
109
109
::: zone pivot="sq1-visual-studio-code"
110
110
111
-
In the **Database Projects** view of VS Code or Azure Data Studio, select the **New Project** button.
111
+
In the **Database Projects** view of Visual Studio Code, select the **New Project** button.
112
112
113
113
:::image type="content" source="media/getting-started/projects-viewlet.png" alt-text="Screenshot of New viewlet.":::
114
114
@@ -161,11 +161,11 @@ More database objects can be added through the **Add New Item** dialog, such as
161
161
162
162
::: zone pivot="sq1-visual-studio-code"
163
163
164
-
In the **Database Projects** view of VS Code or Azure Data Studio, right-click the project node and select **Add Table**. In the dialog that appears, specify the table name.
164
+
In the **Database Projects** view of Visual Studio Code, right-click the project node and select **Add Table**. In the dialog that appears, specify the table name.
165
165
166
166
The table is opened in the text editor with the template table definition, where you can add columns, indexes, and other table properties. Save the file when you're done making the initial edits.
167
167
168
-
More database objects can be added through the context menu on the project node, such as views, stored procedures, and functions. Access the dialog by right-clicking the project node in **Database Projects** view of VS Code or Azure Data Studio, then the desired object type. Files in the project can be organized into folders through the **New Folder** option under **Add**.
168
+
More database objects can be added through the context menu on the project node, such as views, stored procedures, and functions. Access the dialog by right-clicking the project node in **Database Projects** view of Visual Studio Code, then the desired object type. Files in the project can be organized into folders through the **New Folder** option under **Add**.
169
169
170
170
::: zone-end
171
171
@@ -206,7 +206,7 @@ The output window automatically opens to display the build process. If there are
206
206
207
207
::: zone pivot="sq1-visual-studio-code"
208
208
209
-
In the **Database Projects** view of VS Code or Azure Data Studio, right-click the project node and select **Build**.
209
+
In the **Database Projects** view of Visual Studio Code, right-click the project node and select **Build**.
210
210
211
211
The output window automatically opens to display the build process. If there are errors or warnings, they're displayed in the output window. On a successful build, the build artifact (`.dacpac` file) is created its location is included in the build output (default is `bin/Debug/projectname.dacpac`).
212
212
@@ -253,7 +253,7 @@ Specify a database name and select **Publish** to deploy the project to the targ
253
253
254
254
::: zone pivot="sq1-visual-studio-code"
255
255
256
-
In the **Database Projects** view of VS Code or Azure Data Studio, right-click the project node and select **Publish**.
256
+
In the **Database Projects** view of Visual Studio Code, right-click the project node and select **Publish**.
257
257
258
258
> [!TIP]
259
259
> If you don't have an available SQL instance for deployment, the SQL Database Projects extension can create a local SQL Server instance for you in a new container. With a container runtime such as Docker Desktop running, select **Publish to a new SQL server local development container** from the dropdown list.
Copy file name to clipboardExpand all lines: docs/tools/sql-database-projects/howto/add-existing-files-to-sql-project.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,8 @@ title: Add Existing Files to a SQL Project
3
3
description: "How to add the contents of a dacpac or SQL scripts to a project."
4
4
author: dzsquared
5
5
ms.author: drskwier
6
-
ms.reviewer: maghan
7
-
ms.date: 09/10/2024
6
+
ms.reviewer: maghan, randolphwest
7
+
ms.date: 01/29/2026
8
8
ms.service: sql
9
9
ms.subservice: sql-database-projects
10
10
ms.topic: how-to
@@ -27,15 +27,15 @@ As a concept, once a SQL project is created, objects can be added to it one at a
27
27
28
28
## Import from a `.dacpac` file
29
29
30
-
A `.dacpac` file is a compiled database model and requires specific tooling to read and apply the file. A `.dacpac` file can be generated as a SQL project build artifact or from an existing database, and you may be provided with one with no access to the source. In addition to the many tools that can apply a `.dacpac` to a database, SQL Server Data Tools (SSDT) in Visual Studio can import the contents of a `.dacpac` file directly into a project. The ability to import schema from a database or a .dacpac file is only available if there are no schema objects already defined in the project.
30
+
A `.dacpac` file is a compiled database model and requires specific tooling to read and apply the file. A `.dacpac` file can be generated as a SQL project build artifact or from an existing database, and you might be provided with one with no access to the source. In addition to the many tools that can apply a `.dacpac` to a database, SQL Server Data Tools (SSDT) in Visual Studio can import the contents of a `.dacpac` file directly into a project. The ability to import schema from a database or a .dacpac file is only available if there are no schema objects already defined in the project.
31
31
32
32
:::image type="content" source="media/add-existing-files-to-sql-project/vs-import-menu.png" alt-text="Screenshot of the import menu on a SQL project in Visual Studio SSDT.":::
33
33
34
34
On import, object definitions are scripted into project files using SSDT's organizational defaults for new objects: new files for top level objects, hierarchical children defined in the same file as the parent, table/column constraints defined inline where possible. For more targeted visibility and control for each object, use Schema Compare instead of Import. If the import source contains Pre- and Post-Deployment Scripts, RefactorLogs, or SQLCMD variable definitions, they are imported into the project. If the project already contains any one of these artifacts, the imported files are added to an Ignored on Import folder in the project.
35
35
36
36
If Visual Studio and SQL Server Data Tools isn't available, you can either:
37
37
38
-
- Use the Schema Compare extension in Azure Data Studio to compare the contents of a `.dacpac` file to a project, then selectively apply the changes to the project.
38
+
- Use the Schema Compare extension in Visual Studio Code to compare the contents of a `.dacpac` file to a project, then selectively apply the changes to the project.
39
39
- Use the [SqlPackage](../../sqlpackage/sqlpackage.md) command-line utility to import the contents of a `.dacpac` file into a database, then [create a project from the database](../tutorials/start-from-existing-database.md).
40
40
41
41
## Import from SQL scripts
@@ -62,11 +62,11 @@ More information on [pre/post deployment scripts](../concepts/pre-post-deploymen
62
62
63
63
SQL Server Data Tools (SSDT) in Visual Studio also has the capability to process the contents of SQL scripts while adding them to an original-style project. During this processing, if a script contains an object already defined in the project, the object's definition are updated to match the script. If the script contains an object not already defined in the project, a new file is created for the object.
64
64
65
-
There are known issues where the script processing may result in duplicate constraint and encryption key statements. If you encounter these issues, utilize the build output window to identify the source of the duplicates and manually remove them from the project.
65
+
There are known issues where the script processing might result in duplicate constraint and encryption key statements. If you encounter these issues, utilize the build output window to identify the source of the duplicates and manually remove them from the project.
66
66
67
67
The Import from Script process doesn't incorporate Pre/Post-Deployment scripts, SQLCMD variables, or RefactorLog files. These and any other unsupported constructs that are detected on import are placed in a ScriptsIgnoredOnImport.sql file in a Scripts folder in your project.
68
68
69
69
## Related content
70
70
71
-
-[Create a project from a database](../tutorials/start-from-existing-database.md)
0 commit comments