sql-server - 挂火后台作业给出 SQL 异常:登录失败
问题描述
我遵循的教程 - https://docs.hangfire.io/en/latest/getting-started/aspnet-core-applications.html
在启动类中配置服务
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IBackgroundJobClient backgroundJobs)
{
app.UseHangfireDashboard();
backgroundJobs.Enqueue(() => Console.WriteLine("Hello world from Hangfire!"));
}
SqlException:无法打开登录请求的数据库“HangfireTest”。登录失败。用户“PENGUIN\PC”登录失败。
当我运行应用程序时出现此异常?
解决方案
我可以通过更改 apsettings.json 文件中的连接字符串来解决这个问题,如果您需要找到连接字符串,请右键单击 Visual Studio 的 SQl 服务器对象资源管理器的数据库实例 - > 属性并获取连接字符串。此连接字符串应与 appsettings.json 一起放置
"ConnectionStrings": {
"ApplicationDbContext": "server=(localdb)\\mssqllocaldb;Database=ApplicationDbContext;Trusted_Connection=True;MultipleActiveResultSets=true",
"HangfireConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=master;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
推荐阅读
- android - SurfaceViewRenderer 视图无法在屏幕上拖动 Android WebRTC
- javascript - Firebase Firestore 如何添加子集合
- routes - 如何处理 Symfony 4.4 URL 历史记录?
- postgresql - 数百万行的飞行路线
- reactjs - 如何使我的布局适应 Material-UI 工具栏的高度?
- mysql - 如何将数据保存到 MySQL 中的 BLOB 变量中?
- php - Angularjs如何处理来自php(json)的二维数组
- google-apps-script - 如何使用 appscript 将联系人照片添加到 google-contact
- angular - portlet angular中的服务构建器liferay
- class - 如何从同一个类中获取值并打印 w/o excel?