This update brings the below changes over the previous preview release:
- Added missing
SqlClientLogger
class to .NET Core refs and missingSqlClientLogger.LogWarning
method in .NET Framework refs #1392
- Avoid throwing unnecessary exception when an invalid
SqlNotificationInfo
value is received from SQL Server #1378 - Updated
Microsoft.Data.SqlClient.SNI
(.NET Framework dependency) andMicrosoft.Data.SqlClient.SNI.runtime
(.NET Core/Standard dependency) version tov4.0.0
#1391
All changes in Microsoft.Data.SqlClient v4.0 over v3.0:
- Added
SqlCommand.EnableOptimizedParameterBinding
property that when enabled increases performance for commands with very large numbers of parameters. #1041 Read more - Included
42108
and42109
error codes to retriable transient errors list. #1215 - Added new App Context switch to use OS enabled client protocols only. #1168. Read more
- Added
PoolBlockingPeriod
connection property support in .NET Standard. #1181 - Added support for
SqlDataReader.GetColumnSchema()
in .NET Standard. #1181 - Added PropertyGrid support with component model annotations to
SqlConnectionStringBuilder
properties for .NET Core. #1152 - Added support for
SqlFileStream
on Windows using .NET Standard 2.0 and above. #1240 - Added support for localdb
shared instance
using managed SNI. #1237. Read more - Added
GetFieldValueAsync<T>
andGetFieldValue<T>
support forXmlReader
,TextReader
,Stream
#1019. Read more - Added missing
SqlClientLogger
class to .NET Core refs and missing 'SqlClientLogger.LogWarning' method in .NET Framework refs #1392
- Fixed issue with connectivity when TLS 1.3 is enabled on client and server. #1168
- Fixed issue with connection encryption to ensure connections fail when encryption is required. #1210 Read more
- Fixed issue where connection goes to unusable state. #1128
- Fixed recursive calls to
RetryLogicProvider
when callingSqlCommand.ExecuteScalarAsync
. #1220 - Fixed async deadlock scenarios in web contexts with configurable retry logic provider. #1220
- Fixed
EntryPointNotFoundException
inInOutOfProcHelper
constructor. #1120 - Fixed async thread blocking issues on
SqlConnection.Open()
for active directory authentication modes. #1213 - Fixed driver behavior for Always Encrypted with secure enclaves to not fail when no user parameters have been provided. #1115
- Fixed bug with
LegacyRowVersionNullBehavior
App Context switch. #1182 - Fixed issues in Strings.resx file containing error messages. #1136 #1178
- Fixed
.NET decimal
conversion fromSqlDecimal
. #1179 - Fixed
Event Source
changes on TryBeginExecuteEvent and WriteEndExecuteEvent to address the failure on other MS products such as OpenTelemetry and Application Insight. #1258 - Fixed deadlock in transaction using .NET Framework. #1242
- Fixed unknown transaction state issues when prompting delegated transaction. 1216
- Fixed
FormatException
when opening a connection with event tracing enabled #1291 - Fixed improper initialization of
ActiveDirectoryAuthenticationProvider
#1328 - Fixed
MissingMethodException
when accessingSqlAuthenticationParameters.ConnectionTimeout
#1336 - Fixed bug where environment variables are ignored when using
Active Directory Default
authentication #1360
- Updated error code to match with Windows when certificate validation fails in non-Windows client environments. #1130
- Removed designer attributes from
SqlCommand
andSqlDataAdapter
. #1132 - Updated configurable retry logic default retriable error list. #1125
- Improved performance by changing
SqlParameter
bool fields to flags. #1064 - Improved performance by implementing static delegates. #1060
- Optimized async method allocations in .NET Framework by porting changes from .NET Core. #1084
- Various code improvements #902 #925 #933 #934 #1024 #1057 #1122 #1133 #1134 #1141 #1155 #1187 #1188 #1223 #1225 #1226 #1236 #1251 #1266
- Removed attributes for classes used in Microsoft.VSDesigner due to lack of support for Microsoft.Data.SqlClient #1296
- Disable encryption when connecting to SQL LocalDB #1312
- Avoid throwing unnecessary exception when an invalid SqlNotificationInfo value is received from SQL Server #1378
- Updated
Microsoft.Data.SqlClient.SNI
(.NET Framework dependency) andMicrosoft.Data.SqlClient.SNI.runtime
(.NET Core/Standard dependency) version tov4.0.0
#1391 - Various code health and performance improvements. See milestone for more info.
- Changed
Encrypt
connection string property to betrue
by default. #1210 Read more - The driver now throws
SqlException
replacingAggregateException
for active directory authentication modes. #1213 - Dropped obsolete
Asynchronous Processing
connection property from .NET Framework. #1148 - Removed
Configurable Retry Logic
safety switch. #1254 Read more - Dropped support for .NET Core 2.1 #1272
- [.NET Framework] Exception will not be thrown if a User ID is provided in the connection string when using
Active Directory Integrated
authentication #1359
The default value of the Encrypt
connection setting has been changed from false
to true
. With the growing use of cloud databases and the need to ensure those connections are secure, it's time for this backwards-compatibility-breaking change.
In scenarios where client encryption libraries were disabled or unavailable, it was possible for unencrypted connections to be made when Encrypt was set to true or the server required encryption.
TLS 1.3 is not supported by the driver; therefore, it has been removed from the supported protocols list by default. Users can switch back to forcing use of the Operating System's client protocols, by enabling the App Context switch below:
Switch.Microsoft.Data.SqlClient.UseSystemDefaultSecureProtocols
Microsoft.Data.SqlClient introduces a new SqlCommand
API, EnableOptimizedParameterBinding
to improve performance of queries with a large number of parameters. This property is disabled by default. When set to true
, parameter names will not be sent to the SQL server when the command is executed.
public class SqlCommand
{
public bool EnableOptimizedParameterBinding { get; set; }
}
The App Context switch "Switch.Microsoft.Data.SqlClient.EnableRetryLogic" will no longer be required to use the configurable retry logic feature. The feature is now supported in production. The default behavior of the feature will continue to be a non-retry policy, which will need to be overridden by client applications to enable retries.
SqlLocalDb shared instances are now supported when using Managed SNI.
- Possible scenarios:
(localdb)\.
(connects to default instance of SqlLocalDb)(localdb)\<named instance>
(localdb)\.\<shared instance name>
(*newly added support)
XmlReader
, TextReader
, Stream
types are now supported when using GetFieldValueAsync<T>
and GetFieldValue<T>
.
Example usage:
using (SqlConnection connection = new SqlConnection(connectionString))
{
using (SqlCommand command = new SqlCommand(query, connection))
{
connection.Open();
using (SqlDataReader reader = await command.ExecuteReaderAsync())
{
if (await reader.ReadAsync())
{
using (Stream stream = await reader.GetFieldValueAsync<Stream>(1))
{
// Continue to read from stream
}
}
}
}
}
- .NET Framework 4.6.1+ (Windows x86, Windows x64)
- .NET Core 3.1+ (Windows x86, Windows x64, Windows ARM64, Windows ARM, Linux, macOS)
- .NET Standard 2.0+ (Windows x86, Windows x64, Windows ARM64, Windows ARM, Linux, macOS)
- Microsoft.Data.SqlClient.SNI 4.0.0
- Azure.Identity 1.3.0
- Microsoft.Identity.Client 4.22.0
- Microsoft.IdentityModel.JsonWebTokens 6.8.0
- Microsoft.IdentityModel.Protocols.OpenIdConnect 6.8.0
- System.Buffers 4.5.1
- System.Configuration.ConfigurationManager 5.0.0
- System.IO 4.3.0
- System.Runtime.InteropServices.RuntimeInformation 4.3.0
- System.Security.Cryptography.Algorithms 4.3.1
- System.Security.Cryptography.Primitives 4.3.0
- System.Text.Encodings.Web 4.7.2
- Microsoft.Data.SqlClient.SNI.runtime 4.0.0
- Azure.Identity 1.3.0
- Microsoft.Identity.Client 4.22.0
- Microsoft.IdentityModel.Protocols.OpenIdConnect 6.8.0
- Microsoft.IdentityModel.JsonWebTokens 6.8.0
- Microsoft.Win32.Registry 5.0.0
- System.Buffers 4.5.1
- System.Configuration.ConfigurationManager 5.0.0
- System.Diagnostics.DiagnosticSource 5.0.0
- System.IO 4.3.0
- System.Runtime.Caching 5.0.0
- System.Text.Encoding.CodePages 5.0.0
- System.Text.Encodings.Web 4.7.2
- System.Resources.ResourceManager 4.3.0
- System.Security.Cryptography.Cng 5.0.0
- System.Security.Principal.Windows 5.0.0
- Microsoft.Data.SqlClient.SNI.runtime 4.0.0
- Azure.Identity 1.3.0
- Microsoft.Identity.Client 4.22.0
- Microsoft.IdentityModel.Protocols.OpenIdConnect 6.8.0
- Microsoft.IdentityModel.JsonWebTokens 6.8.0
- Microsoft.Win32.Registry 5.0.0
- System.Buffers 4.5.1
- System.Configuration.ConfigurationManager 5.0.0
- System.IO 4.3.0
- System.Runtime.Caching 5.0.0
- System.Text.Encoding.CodePages 5.0.0
- System.Text.Encodings.Web 4.7.2
- System.Resources.ResourceManager 4.3.0
- System.Runtime.Loader 4.3.0
- System.Security.Cryptography.Cng 5.0.0
- System.Security.Principal.Windows 5.0.0