0

In our project we need to implement Active Directory authentication for SQL Server. The project is using the .NET framework, and we are making use of Entity Framework. We are making use of Active Directory service principal in connection string.

I have mentioned the provider as System.Data.EntityClient in the EF connection string. I was able to establish connection for ado.net.

This is the normal connection string

Server=DemoDB.database.windows.net; Authentication=Active Directory Service Principal; Encrypt=True; Database=SQLDevDB; MultipleActiveResultSets=True; User Id=*****; Password=*****

Here's the Entity Framework connection string

metadata=res://*/DemoDB.csdl|res://*/DemoDB.ssdl|res://*/DemoDB.msl;provider=System.Data.EntityClient;provider connection string='{0}'";

We get this exception from Entity Framework:

System.ArgumentException: 'The ADO.NET provider with invariant name 'System.Data.EntityClient' is either not registered in the machine or application config file,or could not be loaded. See the inner exception for details.'

Please help me with these issues.

Thanks

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Please oh please share your connection string .... – ErikEJ Jun 27 '23 at 16:40
  • Below is the normal connection string Server=DemoDB.database.windows.net; Authentication=Active Directory Service Principal; Encrypt=True; Database=SQLDevDB; MultipleActiveResultSets=True; User Id=*****; Password=***** – Saurabh Agrawal Jun 27 '23 at 16:45
  • Below is the entity framework connection string "metadata=res://*/DemoDB.csdl|res://*/DemoDB.ssdl|res://*/DemoDB.msl;provider=System.Data.EntityClient;provider connection string='{0}'"; – Saurabh Agrawal Jun 27 '23 at 16:47
  • @ErikEJ please refer the above connection strings – Saurabh Agrawal Jun 27 '23 at 16:48
  • [Edit] your question @SaurabhAgrawal . The comments aren't for information that needs to be in the question. – Thom A Jun 27 '23 at 16:58
  • @ThomA my question is what I facing the issue – Saurabh Agrawal Jun 27 '23 at 17:01
  • And you need to [edit] it to add the information that was asked for ,@SaurabhAgrawal . Those comments shouldn't be comments; they **need** to be in the question. – Thom A Jun 27 '23 at 17:02
  • Try to install the "System.Data.SqlClient" package from nuget Package manager and try to use this as provider. – Bhavani Jun 29 '23 at 10:46

1 Answers1

0

I got the similar error while connecting to database.

enter image description here

I installed System.Data.SqlClient from NuGet packet Manager

enter image description here

My issue resolved after the package installation.

  • Make sure register the Entity Framework provider for the System.Data.SqlClient SQL connection type.
  • Ensure EntityFramework.SqlServer.dll is being copied to the bin directory.

For more information you can refer this.

Bhavani
  • 1,725
  • 1
  • 3
  • 6