[英]How to pass appsettings.json text as a SQL connection string in Model class? (Specific example)
[英]SQL Connection String appsettings.json
這是我的連接字符串
{
"Data": {
"PhotoGalleryConnection": {
"ConnectionString": "Server=WINDOWS-B7MJR5T\\SQLEXPRESS;User Id=sa;password=allah;Database=PhotoGallery;Trusted_Connection=True;MultipleActiveResultSets=true"
}
}
}
我正面臨這個例外
Microsoft.EntityFrameworkCore.dll 中發生類型為“System.Data.SqlClient.SqlException”的異常,但未在用戶代碼中處理附加信息:無法打開登錄請求的數據庫“PhotoGallery”。 登錄失敗。
刪除Trusted_Connection = True后,它應該可以工作; 從連接字符串。
如果您指定Trusted_Connection = True; 或Integrated Security = SSPI; 或Integrated Security = true; 在您的連接字符串中(然后(僅那時))中,您正在進行Windows身份驗證。 連接字符串中的任何用戶id =設置都將被忽略。 在此處找到: 使用Trusted_Connection = true和SQL Server身份驗證時,這會影響性能嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.