.NET Core can´t connect to SQL DB

前端 未结 3 993
梦毁少年i
梦毁少年i 2021-01-02 07:02

I build a new .net Core Web API with connection to SQL DB. I have problems to connect the API with my Database I tried a local DB \"DefaultConnection\": \"Server=(loca

3条回答
  •  长发绾君心
    2021-01-02 07:57

    We hit a similar (or identical?) issue. .NET Core didn't work with a connection string but .NET Framework worked just fine with that same string. It turned out to be because our connection string was using an SQL Alias rather than the IP hostname of the database server, and .NET Core dropped SQL Alias support because it was too Windowsy/registry-y.

    Changing the connection string to use the IP hostname or number resolved the issue.

    • .NET team discussion on issue: https://github.com/dotnet/corefx/issues/2575
    • Related SO issue: Issues with SQL Alias in ConnectionString in appsettings.json for instance.

提交回复
热议问题