gpt4 book ai didi

docker - 如何在Mac上将ASP.Net Core连接到SQL Server Docker容器

转载 作者:行者123 更新时间:2023-12-04 08:40:11 25 4
gpt4 key购买 nike

我正在使用Mac上的Visual Studio 2017开发ASP.Net核心MVC应用程序。但是,连接到在Docker容器上运行的SQL Server实例时遇到一些问题。

这是我正在使用的连接字符串:

"ConnectionStrings": {
"myCustomConnString": "Server=localhost;Database=myDataBase;User Id=sa;Password=myPassw0rd;Trusted_Connection=True;MultipleActiveResultSets=true"
}

这是我得到的错误:

Cannot authenticate using Kerberos. Ensure Kerberos has been initialized on the client with 'kinit' and a Service Principal Name has been registered for the SQL Server to allow Kerberos authentication. ErrorCode=InternalError, Exception=Interop+NetSecurityNative+GssApiException: GSSAPI operation failed with error - An unsupported mechanism was requested (unknown mech-code 0 for mech unknown).



使用SQL Operation Studio,Azure Data Studio和/或Visual Studio Code并传递相同的参数,我可以连接到SQL Server的docker实例。但是在运行ASP.Net核心应用程序时不行。因此,我不确定是否缺少连接字符串的任何其他参数。

有人试过吗?

问候!

最佳答案

我知道@MikePR的评论可以作为答案,但我想为我遇到的问题提供更完整的答案。将连接字符串与dotnet ef database结合使用后,我无法获得Trusted_Connection=false命令来执行evan。借助this article,我可以使用以下连接字符串:

"ConnectionStrings": {
"myCustomConnString": "Server=localhost,1433\\Catalog=myDatabase;Database=myDatabase;User=username;Password=MYSecurePWD;"
}

现在,我的迁移针对Docker容器中的SQL Server运行。请注意,本文不包括使用 Trusted_Connection=false。我认为false是默认值。

关于docker - 如何在Mac上将ASP.Net Core连接到SQL Server Docker容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53024227/

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