gpt4 book ai didi

json - 键 'authentication' 的值无效

转载 作者:行者123 更新时间:2023-12-02 22:49:18 25 4
gpt4 key购买 nike

我有一个 .NET Core 3.0 应用程序,正在尝试使用 EF Core 和 Active Directory 集成身份验证连接到 Azure SQL 数据库。
我已验证我可以从我的计算机访问此数据库,因为我可以使用 SQL Server Management Studio 和“Azure Active Directory 集成”身份验证很好地连接到它。

但是,当我尝试读取应用程序中的数据(使用 EF Core)时,我总是收到 System.Argument 异常,并显示以下语句:

key “身份验证”值无效

异常详细信息指向数据库连接字符串。

所以,这是我的 dev appsettings.json 文件中的连接字符串:

"ConnectionStrings": {"MCDB": "Server=tcp:dev-media-center-sql.database.windows.net,1433;InitialCatalog=MediaCenter;Persist Security Info=False;UserID={my User ID};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Authentication=Active Directory Integrated;" },

我尝试直接在代码中对连接字符串进行硬编码,认为我的 JSON 可能有问题,但我仍然遇到相同的异常。

“Active Directory Integrated”是否不是“身份验证”关键字的有效值?如果不是,那是什么?我已经尝试过“ActiveDirectoryIntegrated”(不带空格)和/“Active Directory Integrated”/(转义双引号)但无济于事。

最佳答案

如果您将 EF Core 与 Microsoft.EntityFrameworkCore.SqlServer 包一起使用,请注意 Microsoft Learn 中的此提示EF Core 数据库提供商页面:

The Microsoft.Data.SqlClient package ships more frequently than the EFCore provider. If you would like to take advantage of new features andbug fixes, you can add a direct package reference to the latestversion of Microsoft.Data.SqlClient.

话虽如此,修复方法是将包添加到您的项目中:

cropped screenshot showing the "Microsoft.Data.SqlClient NuGet" package selected for installation in a user's Solution file in Visual Studio.

关于json - 键 'authentication' 的值无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59654712/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com