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

标签 docker asp.net-core .net-core asp.net-core-mvc .net-mac

我正在使用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/

相关文章:

Bash 和 Docker : strange heredoc behavior with read loop

image - 如何更新docker镜像而不丢失其内容?

docker:如何使所有设备可用?

c# - 如何使用 c# .net 核心 Entity Framework 执行连接

c# - 英孚核心 2.1。将自定义列添加到 MigrationHistory 表

docker - 访问 Dockerfile 中的 OpenShift 模板参数

c# - Asp.net 5 web api返回状态代码和正文

c# - 无法解析类型 'System.Net.Http.HttpClient' 的服务

visual-studio - 为什么我安装后 .NET Core 3.1 没有出现在 Visual Studio 中?

c# - 尝试激活 'Microsoft.AspNetCore.Identity.UserManager' 时无法解析类型 'WebShop.Controllers.User.UserController' 的服务