简体   繁体   English

SQL 连接字符串 appsettings.json

[英]SQL Connection String appsettings.json

This is my connection string这是我的连接字符串

{
  "Data": {
    "PhotoGalleryConnection": {
      "ConnectionString": "Server=WINDOWS-B7MJR5T\\SQLEXPRESS;User Id=sa;password=allah;Database=PhotoGallery;Trusted_Connection=True;MultipleActiveResultSets=true"
    }
  }
}

And I am facing this exception我正面临这个例外

An exception of type 'System.Data.SqlClient.SqlException' occurred in Microsoft.EntityFrameworkCore.dll but was not handled in user code Additional information: Cannot open database "PhotoGallery" requested by the login. Microsoft.EntityFrameworkCore.dll 中发生类型为“System.Data.SqlClient.SqlException”的异常,但未在用户代码中处理附加信息:无法打开登录请求的数据库“PhotoGallery”。 The login failed.登录失败。

It should work after You delete Trusted_Connection=True; 删除Trusted_Connection = True后,它应该可以工作; from connection string. 从连接字符串。

If you specify either Trusted_Connection=True; 如果您指定Trusted_Connection = True; or Integrated Security=SSPI; 或Integrated Security = SSPI; or Integrated Security=true; 或Integrated Security = true; in your connection string THEN (and only then) you have Windows Authentication happening. 在您的连接字符串中(然后(仅那时))中,您正在进行Windows身份验证。 Any user id= setting in the connection string will be ignored. 连接字符串中的任何用户id =设置都将被忽略。 Found in here: When using Trusted_Connection=true and SQL Server authentication, will this effect performance? 在此处找到: 使用Trusted_Connection = true和SQL Server身份验证时,这会影响性能吗?

请在窗口菜单中搜索服务

Please search services in the window menu, it will show you the local services then go to SQL server services and refresh all, then go to the SQL server management studio and by using SQL authentication please provide username and password, you will be able to use the SQL server.请在window菜单中搜索服务,它将显示本地服务然后go到SQL服务器服务并刷新所有,然后go到SQL服务器管理工作室并通过使用SQL,身份验证将能够使用您提供用户名和密码SQL 服务器。 for appsetting.json update, trusted_connection is used for window authentication not for SQL server authentication by using username and password对于 appsetting.json 更新,trusted_connection 用于 window 身份验证,而不是使用用户名和密码进行 SQL 服务器身份验证

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将appsettings.json文本作为Model类中的SQL连接字符串传递? (具体例子) - How to pass appsettings.json text as a SQL connection string in Model class? (Specific example) 在 appsettings.json 中的连接字符串中转义双引号 - Escaping double quotes in connection string in appsettings.json 如何在 appsettings.json 中设置连接字符串? - How do I set up a connection string into appsettings.json? 无法从appsettings.json获取连接字符串 - Cannot get connection string from appsettings.json 使用从appsettings.json到startup.cs的连接字符串 - Using connection string from appsettings.json to startup.cs .Net Core Cant从appsettings.json中读取连接字符串 - .Net Core Cant read connection string from appsettings.json .NET Core从appsettings.json获取连接字符串 - .NET Core get connection string from appsettings.json 如何从 DotNetCore 2.2 中的 appsettings.json 读取连接字符串? - How to read connection string from appsettings.json in DotNetCore 2.2? 如何加密/解密 appsettings.json 中的连接字符串? - How to encrypt/decrypt connection string in appsettings.json? 由于 appsettings.json 的路径,add-migration 无法从文件 appsettings.json 读取连接字符串 - add-migration can not read the connection string from the file appsettings.json because of the path to appsettings.json
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM