SQL Database Projects extension (Preview)

The SQL Database Projects extension (preview) is an Azure Data Studio and Visual Studio Code extension for developing SQL databases including for SQL Server, Azure SQL Database, and Azure SQL Managed Instance in a project-based development environment. A SQL project is a local representation of SQL objects that comprise the schema for a single database, such as tables, stored procedures, or functions.

Extension features

The SQL Database Projects extension provides the following features:

  • Create a new blank project.
  • Create a new project from a connected database or from an OpenAPI specification file.
  • Open a project previously created in Azure Data Studio, Visual Studio Code or in SQL Server Data Tools.
  • Edit a project by adding or removing objects (tables, views, stored procedures) or custom scripts in the project.
  • Organize files/scripts in folders.
  • Add references to system databases or a user dacpac.
  • Build a single project.
  • Deploy a single project.
  • Load connection details (SQL Windows authentication) and SQLCMD variables from deployment profile.

Watch this short 10-minute video for an introduction to the SQL Database Projects extension in Azure Data Studio:

Install

You can install the SQL Database Project extension in Azure Data Studio and Visual Studio Code.

Azure Data Studio

To install the SQL Database Project extension in Azure Data Studio, follow these steps:

  1. Open the extensions manager to access the available extensions. To do so, either select the extensions icon or select Extensions in the View menu.

  2. Identify the SQL Database Projects extension by typing all or part of the name in the extension search box. Select an available extension to view its details.

    Screenshot of Azure Data Studio, Install extension.

  3. Select the extension you want and choose to Install it.

  4. Select Reload to enable the extension (only required the first time you install an extension).

  5. Select the Projects icon from the activity bar.

Note

  • It is recommended to install the Schema Compare extension alongside the SQL Database Projects extension for full functionality.

Visual Studio Code

The SQL Database Projects extension is installed with the mssql extension for Visual Studio Code.

Dependencies

The SQL Database Projects extension has a dependency on the .NET Core SDK and AutoRest.Sql

.NET Core SDK

The .NET Core SDK is required for project build functionality and you are prompted to install the .NET Core SDK if a supported version can't be detected by the extension. The .NET Core SDK can be downloaded and installed for Windows, macOS, and Linux.

If you would like to check currently installed versions of the dotnet SDK, open a terminal and run the following command:

dotnet --list-sdks

To force the SQL Database Projects extension to use the v6.x version of the .NET Core SDK when multiple versions are installed, add a package.json file to the folder that contains the SQL project.

Unsupported .NET Core SDK versions may result in error messages such as:

  • error MSB4018: The "SqlBuildTask" task failed unexpectedly.
  • error MSB4018: System.TypeInitializationException: The type initializer for 'SqlSchemaModelStaticState' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. [c:\Users\ .sqlproj]_ (where the linked non-existing file has an unmatched closing square bracket).

AutoRest.Sql

The SQL extension for AutoRest is automatically downloaded and used by the SQL Database Projects extension when a SQL project is generated from an OpenAPI specification file.

Limitations

Currently, the SQL Database Project extension has the following limitations:

  • Loading files as a link isn't supported in Azure Data Studio today, however the files are loaded at the top level in the tree and the build incorporates these files as expected.
  • SQLCLR objects in projects aren't supported in the.NET Core version of DacFx.
  • Tasks (build/publish) aren't user-defined.
  • Publish targets defined by DacFx.
  • WSL environment support is limited.

Workspace

SQL database projects are contained within a logical workspace in Azure Data Studio and Visual Studio Code. A workspace manages the folder(s) visible in the Explorer pane. All SQL projects within the folders open in the current workspace are available in the SQL Database Projects view by default.

You can manually add and remove projects from a workspace through the interface in the Projects pane. The settings for a workspace can be manually edited in the .code-workspace file, if necessary.

In the following example .code-workspace file, the folders array lists all folders included in the Explorer pane and the dataworkspace.excludedProjects array within settings lists all the SQL projects included in the Projects pane.

{
	"folders": [
		{
			"path": "."
		},
		{
			"name": "WideWorldImportersDW",
			"path": "..\\WideWorldImportersDW"
		}
	],
	"settings": {
		"dataworkspace.excludedProjects": [
			"AdventureWorksLT.sqlproj"
		]
	}
}

Next steps