Skip to content

Commit 9684c4f

Browse files
authored
Merge pull request #11873 from ghogen/add-new-connections-nov-2023
Add info for Encrypt and Trust Server Certificate options for MDS 4.0 and VS 17.8
2 parents ced3e7e + d3128e4 commit 9684c4f

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

docs/data-tools/add-new-connections.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Connect to a database or open an MDF file in Visual Studio
3+
ms.date: 11/09/2023
34
description: Connect to a database or data service with ADO.NET in Visual Studio, or connect to a database opened from a median disk file (.mdf).
4-
ms.date: 03/07/2023
55
ms.topic: how-to
66
author: ghogen
77
ms.author: ghogen
@@ -12,8 +12,6 @@ ms.technology: vs-data-tools
1212

1313
[!INCLUDE [Visual Studio](~/includes/applies-to-version/vs-windows-only.md)]
1414

15-
[!INCLUDE [Data access tech note](./includes/data-technology-note.md)]
16-
1715
The steps in this article show how to connect to a data source in the Visual Studio IDE. The data source can be a local database, online data service, or a database opened from an `.mdf` file. You can work directly with your data in Visual Studio. You can execute queries, edit data, create and edit tables and other schema properties, edit stored procedures and functions, triggers, and so on. These functions are independent of the programming language or .NET version you are using.
1816

1917
## Server Explorer and SQL Server Object Explorer
@@ -58,14 +56,39 @@ To create a connection to the database, click the **Connect to database** icon i
5856

5957
This brings up the **Add Connection** dialog box. Here, we have entered the name of the SQL Server LocalDB instance, `(localdb)\MSSqlLocalDB`, which is usually installed with Visual Studio.
6058

59+
If you don't have access to another database, and you don't see LocalDB installed, you can install LocalDB through the Visual Studio Installer, as part of the **Data storage and processing** workload, the **ASP.NET and web development** workload, or as an individual component. See [Modify Visual Studio](../install/modify-visual-studio.md).
60+
6161
:::moniker range="<=vs-2019"
6262
![Screenshot of Add New Connection dialog box.](../data-tools/media/add-new-connection-dialog.png)
6363
:::moniker-end
6464
:::moniker range=">=vs-2022"
65-
![Screenshot of Add New Connection dialog box.](./media/vs-2022/add-new-connection.png)
65+
![Screenshot of Add New Connection dialog box.](./media/vs-2022/add-new-connection-with-trust-selected.png)
66+
67+
In Visual Studio 2022 version 17.8 and later, the dialog includes two new options (**Encrypt** and **Trust Server Certificate**) that go into the connection string and affect the security settings used for your connection. These options support the stricter security features of the Microsoft.Data.SqlClient 4.0 database driver. See [Changes in encryption and certificate validation behavior](/sql/connect/ado-net/encryption-and-certificate-validation#changes-in-encryption-and-certificate-validation-behavior).
68+
69+
The recommended security practice is to use encryption and install a certificate on the server for it. See [Encryption and certificate validation](/sql/connect/ado-net/encryption-and-certificate-validation). To opt out of this enhanced security, set **Encrypt** to **Optional (False)**.
70+
71+
If you don't set **Encrypt** to optional with Visual Studio 17.8 or later, which use version 4.0 of the Microsoft.Data.SqlClient, then encryption defaults to mandatory. This is a breaking change from the behavior in earlier versions. If you don't have a valid certificate or don't choose **Trust Server Certificate**, you get the following error message:
72+
73+
> Encryption was enabled on this connection, review your SSL and certificate configuration for the target SQL Server, or enable 'Trust server certificate' in the connection dialog.
74+
>
75+
> **Additional information**
76+
>
77+
> A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.) (Microsoft SQL Server)
78+
6679
:::moniker-end
6780

68-
If you don't have access to another database, and you don't see LocalDB installed, you can install LocalDB through the Visual Studio Installer, as part of the **Data storage and processing** workload, the **ASP.NET and web development** workload, or as an individual component. See [Modify Visual Studio](../install/modify-visual-studio.md).
81+
### Authentication types
82+
83+
You can choose from a variety of authentication types that cover a wide range of scenarios. For details, see [Authentication types](/sql/ssdt/connect-to-an-existing-database-in-sql-server-data-tools#AuthTypes).
84+
85+
:::moniker range=">=vs-2022"
86+
87+
In Visual Studio 17.8 and later, the names of the authentication options for SQL connections have been updated to reflect the name change from Active Directory to Microsoft Entra.
88+
89+
![Screenshot showing authentication types for Visual Studio 17.8 and later.](./media/vs-2022/authentication-options-microsoft-entra.png)
90+
91+
:::moniker-end
6992

7093
### MDF files
7194

Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)