What is the best way to switch from the default System.Data.SqlClient to Microsoft.Data.SqlClient?
For both framework and core, v5.11.
I got it working by overriding the SqlServerSpecificCreator like below but its a bit more involved than I expected so I'm wondering if there is something I'm missing:
using System.Data;
using System.Data.Common;
using System.IO;
using AQD.Helpers;
using Microsoft.Data.SqlClient;
using SD.LLBLGen.Pro.DQE.SqlServer;
namespace AQD.Model.SqlServer
{
class AqdSqlServerSpecificCreator : SqlServerSpecificCreator
{
/// <inheritdoc />
public override DbProviderFactory FactoryToUse => SqlClientFactory.Instance ?? base.FactoryToUse;
/// <inheritdoc />
protected override void SetParameterType(DbParameter parameter, string parameterType)
{
var sqlDbType = GeneralHelper.TryStringToEnum<SqlDbType>(parameterType);
if (sqlDbType == null)
base.SetParameterType(parameter, parameterType);
else
((SqlParameter)parameter).SqlDbType = sqlDbType.Value;
}
}
}