Linux Mint下执行dotnet-ef database update连接SQL Server报错求助
问题解决步骤
核心问题分析
你的连接字符串是针对Windows环境的SQL Server Express配置,但Linux Mint下的SQL Server默认实例名不是sqlexpress,且不支持Integrated Security=True(Windows集成认证),这两点是导致连接失败的关键。
1. 修正连接字符串
将appsettings.Development.json中的连接字符串替换为适配Linux环境的格式:
"ConnectionStrings": { "ConexaoPadrao": "Server=localhost,1433; Initial Catalog=Agenda; User Id=sa; Password=你的SQLServer管理员密码; TrustServerCertificate=True" }
- 移除
\\sqlexpress:Linux版SQL Server默认实例名为MSSQLSERVER,无需指定实例名,直接用localhost或localhost,1433(1433是默认端口) - 替换
Integrated Security=True:Linux不支持Windows域集成认证,改用SQL Server账号认证(默认管理员账号为sa,需填写你安装时设置的密码) - 添加
TrustServerCertificate=True:规避Linux环境下的SSL证书验证报错
2. 确认SQL Server服务状态
执行命令检查服务是否正常运行:
sudo systemctl status mssql-server
若服务未启动,执行启动命令:
sudo systemctl start mssql-server
3. 重新执行迁移命令
配置修改完成后,再次运行:
dotnet-ef database update
内容的提问来源于stack exchange,提问作者niltongc
相关产品推荐
相关产品推荐

