You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 00:45:49