Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using Microsoft.Practices.EnterpriseLibrary.Data to create connection using below code

Database namedDB = EnterpriseLibraryContainer.Current.GetInstance<database>("myConnectionString");

below is my appsetting.json

ConnectionStrings": {
"Default": "Server=CINT-IAOW-014\\***;Database=***;User ID=**;Password=***;Trusted_Connection=False;",
"providerName": "System.Data.SqlClient"
}
but i am getting this error :

Microsoft.Practices.ServiceLocation.ActivationException: 'Activation error occurred while trying to get instance of type Database, key "myConnectionString"'

InvalidOperationException: The current type, Microsoft.Practices.EnterpriseLibrary.Data.Database, is an abstract class and cannot be constructed. Are you missing a type mapping?
Ple

What I have tried:

unable to find any solution on the issue
Posted
Comments
ZurdoDev 3-Feb-20 11:47am    
Lots of possible solutions if you google.
Richard Deeming 3-Feb-20 12:19pm    
You are trying to access a connection string called myConnectionString, but the only connection string in your appSettings file is called Default.

Also, it's not clear whether the Microsoft.Practices.EnterpriseLibrary.Data library supports .NET Core. There's a .NET Core port on GitHub, but I can't immediately tell whether it supports reading connection strings from the appSettings file.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900