SQL连接字符串appsettings.json [英] SQL Connection String appsettings.json

查看:550
本文介绍了SQL连接字符串appsettings.json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的连接字符串

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

我正面临这种例外情况

类型为'System.Data.SqlClient.SqlException'的异常发生在 Microsoft.EntityFrameworkCore.dll,但未在用户代码中处理 附加信息:无法打开请求的数据库"PhotoGallery" 通过登录.登录失败.

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. The login failed.

推荐答案

删除Trusted_Connection = True后应该可以使用;从连接字符串中获取.

It should work after You delete Trusted_Connection=True; from connection string.

如果您指定Trusted_Connection = True;或集成 安全性= SSPI;或Integrated Security = true;在您的连接字符串中 然后(只有那时)您才能进行Windows身份验证.任何 连接字符串中的user id =设置将被忽略.在以下位置找到:使用Trusted_Connection = true和SQL Server身份验证,这会影响性能吗?

If you specify either Trusted_Connection=True; or Integrated Security=SSPI; or Integrated Security=true; in your connection string THEN (and only then) you have Windows Authentication happening. Any user id= setting in the connection string will be ignored. Found in here: When using Trusted_Connection=true and SQL Server authentication, will this effect performance?

这篇关于SQL连接字符串appsettings.json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆