Since SqlDatabase
in Microsoft.EnterpriseLibrary.Data
internally uses System.Data.SqlClient
, you cannot directly replace it without modifying the library. However, you can work around this by replacing SqlDatabase
with custom code that explicitly uses Microsoft.Data.SqlClient
.
Or you can create a custom database class to use Microsoft.Data.SqlClient
for connecting to the Azure database.
Then check if your connection string includes the necessary keywords for Azure SQL Database authentication, such as Authentication=Active Directory Password;
if using Azure AD, or other required authentication modes.
If you're using Microsoft.EnterpriseLibrary.Data
primarily for database access, migrate the relevant parts of your code to use the CustomSqlDatabase
class.
As a recommendation if you are open to using other frameworks, consider switching to:
- Entity Framework Core: A modern ORM that supports
Microsoft.Data.SqlClient
natively. - Dapper: A lightweight ORM with excellent performance and support for
Microsoft.Data.SqlClient
.