什么是正确的sql连接字符串?

时间:2019-05-14 11:47:57

标签: sqlconnection .net-core-2.2

我正在尝试在Debian 9上运行.net core 2.2 Web api。它在我的本地计算机(macOS)上运行良好,但是将其发布到Debian后却显示错误:

"ArgumentException: Keyword not supported: 'datasource'"
 System.Data.Common.DbConnectionOptions.ParseInternal(Dictionary<string, string> parsetable, string connectionString, bool buildChain, Dictionary<string, string> synonyms, bool firstKey)

在Windows计算机上访问MSSql数据库时。

我在appsettings.json文件中尝试了两个连接字符串。

"ConnectionStrings": {
"DefaultConnection": "Server=Server_IP;Database=Database_Name;Persist Security Info=True;User ID=User_ID;Password=*****;MultipleActiveResultSets=true"}

"ConnectionStrings": {
"DefaultConnection": "Data Source=Server_IP;Initial Catalog =Database_Name;Persist Security Info=True;User ID=User_ID;Password=*****;MultipleActiveResultSets=true"}

我可以使用mssql-cli命令从Debian连接到MSSql服务。 dotnet应用无法解析连接字符串的原因是什么?

1 个答案:

答案 0 :(得分:0)

原因是红k服务中的工作目录错误。

[Service]
WorkingDirectory=/application_path/
ExecStart=/usr/bin/dotnet /application_path/execute_package.dll