27 lines
863 B
C#
27 lines
863 B
C#
// En PasswordMigrationUtil/DbConnectionFactory.cs
|
|
using Microsoft.Data.SqlClient;
|
|
using Microsoft.Extensions.Configuration; // Añadir este using
|
|
using System.Data;
|
|
|
|
namespace PasswordMigrationUtil // Ajusta el namespace
|
|
{
|
|
public class DbConnectionFactory
|
|
{
|
|
private readonly string _connectionString;
|
|
|
|
// Cambiamos el constructor para recibir la cadena directamente
|
|
public DbConnectionFactory(string connectionString)
|
|
{
|
|
if (string.IsNullOrEmpty(connectionString))
|
|
{
|
|
throw new ArgumentNullException(nameof(connectionString), "Connection string cannot be null or empty.");
|
|
}
|
|
_connectionString = connectionString;
|
|
}
|
|
|
|
public IDbConnection CreateConnection()
|
|
{
|
|
return new SqlConnection(_connectionString);
|
|
}
|
|
}
|
|
} |