A community member has associated this post with a similar question:
System.ArgumentException: Invalid value for key 'authentication' in connection string

Only moderators can edit this content.

System.ArgumentException: Invalid value for key 'authentication'

Anant Jaiswal 0 Reputation points
2024-11-18T08:17:21.2866667+00:00

Hello,

I am encountering the following exception when my application tries to connect with my SQL Server database:

Unhandled exception. System.ArgumentException: Invalid value for key 'authentication'.
   at Microsoft.Data.Common.DbConnectionStringBuilderUtil.ConvertToAuthenticationType(String keyword, Object value)
   at Microsoft.Data.SqlClient.SqlConnectionStringBuilder.ConvertToAuthenticationType(String keyword, Object value)
   at Microsoft.Data.SqlClient.SqlConnectionStringBuilder.set_Item(String keyword, Object value)
   at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value)
   at Microsoft.Data.SqlClient.SqlConnectionStringBuilder..ctor(String connectionString)

What I’ve Tried:

I’ve reviewed the connection string and noticed that the authentication key seems to be the source of the issue. Here is the connection string I am using:

"DefaultConnection": "Server=tcp:45f-45fe6e-db.database.windows.net,1433;Initial Catalog=WatchTowerWebDev;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;Authentication=Active Directory Default;",

I am getting this error at line with the following exception : -
User's image

I’ve double-checked that the SQL Server supports the type of authentication I’m using, but I’m unsure whether the problem is with how the connection string is formatted or a mismatch in authentication methods.

Environment Details:

  • .NET Version: 8.0.8
  • SQL Server Version: SQL Server 2019
  • Operating System: Windows Server 2019
  • CoreCLR Version: 8.0.824.36612

Question:

What could be causing the System.ArgumentException: Invalid value for key 'authentication' error in my connection string, and how can I resolve it? Specifically, I’m unclear if the issue lies in the format of the authentication key or if there's something else.

Community Center | Not monitored
{count} votes