Can I use a connection string with the System.Data.SqlClient
provider to connect to an Azure SQL Managed Instance? Or just to a Microsoft SQL Server?
If so, should I still use the Windows authentication?
Thanks,
You can use System.Data.SqlClient to connect to Managed Instance.
However, we recommend that you switch to the newer Microsoft.Data.SqlClient instead.
You can use AD Integrated authentication or Azure AD Service Principal authentication
From dotnet/SqlClient:
Microsoft.Data.SqlClient is a data provider for Microsoft SQL Server and Azure SQL Database. Now in General Availability, it is a union of the two System.Data.SqlClient components which live independently in .NET Framework and .NET Core. Going forward, support for new SQL Server features will be implemented in Microsoft.Data.SqlClient.
If you switch from System.Data.SqlClient to Microsoft.Data.SqlClient you have to take care of some porting todos
The FAQ has some additional infos.