如何使用 ubuntu 桌面上的 Entity Framework 核心将 asp.net 核心 MVC 项目连接到本地数据库
how to connect asp.net core MVC project to local DB using Entity Framework Core on ubuntu desktop
我正在 Ubuntu 16.04 桌面上使用 Entity Framework 核心构建一个 asp.net 核心应用程序。
我安装了 SQL 服务器并 运行ning。
我已成功 运行 命令“-dotnet ef migrations Initial”。我准备 运行“-dotnet ef 数据库更新”以允许 EF 连接并在数据库中创建 table,但我在终端上收到此错误:
A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
was not accessible. Verify that the instance name is correct and that
SQL Server is configured to allow remote connections. (provider: TCP
Provider, error: 25 - Connection string is not valid)
它是一个本地数据库,所以我认为我不需要 TCP 提供程序,对吗?
我如何告诉 EF 连接到 SQL 服务器?
在 appsettings.json 文件中指定您的连接字符串
{
"ConnectionStrings": {
"DefaultConnection": "Server=YOUR_SERVER_NAME;Database=DBNAME;User Id=sa;Password=PASSWORD;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning"
}
}
}
我正在 Ubuntu 16.04 桌面上使用 Entity Framework 核心构建一个 asp.net 核心应用程序。 我安装了 SQL 服务器并 运行ning。 我已成功 运行 命令“-dotnet ef migrations Initial”。我准备 运行“-dotnet ef 数据库更新”以允许 EF 连接并在数据库中创建 table,但我在终端上收到此错误:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 25 - Connection string is not valid)
它是一个本地数据库,所以我认为我不需要 TCP 提供程序,对吗? 我如何告诉 EF 连接到 SQL 服务器?
在 appsettings.json 文件中指定您的连接字符串
{
"ConnectionStrings": {
"DefaultConnection": "Server=YOUR_SERVER_NAME;Database=DBNAME;User Id=sa;Password=PASSWORD;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning"
}
}
}