Ashraf Zaman

Ashraf Zaman

  • NA
  • 57
  • 15.3k

How to use EnterpriseLibrary Data Access Block in .NET Core?

Oct 4 2018 3:41 AM
I am trying to Use EnterpriseLibrary in .NET Core application. When I initialize "Database" by "DatabaseProviderFactory" like this
 
_DB = _Factory.Create(dbConnection);
 
it's showing error :
 
System.InvalidOperationException: 'The connection string for the database 'data source=.\MSSQLSERVER16;initial catalog=TestDB;user id=sa;password=abc@123;' does not exist or does not have a valid provider.'
 
I googled but didn't get any help. Is there anyone who can give me a suggestion or an example How can I Initialize "Database" in .NET Core Application. Below is my code snippet.
 
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Common;
public class DbClass
{
DatabaseProviderFactory _Factory = new DatabaseProviderFactory();
public Database _DB = null;
string dbConnection = @"data source=.\MSSQLSERVER16;initial catalog=TestDB;user id=sa;password=abc@123;";
public DbClass()
{
_DB = _Factory.Create(dbConnection);
}
public string Insert()
{
DbCommand cmd = _DB.GetSqlStringCommand("");
return "";
}
}

Answers (4)