SQL Server Express 与 Hangfire 连接问题:用户登录失败
SQL Server Express with Hangfire connect problem : login failed for user
我正在尝试连接到 Hangfire service
中的 SQL Server Express。
我的 Startup.cs
中的代码如下所示:
services.AddHangfire(configuration => configuration
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UseSqlServerStorage(Configuration.GetConnectionString("HangfireConnection"), new SqlServerStorageOptions
{
CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
QueuePollInterval = TimeSpan.Zero,
UseRecommendedIsolationLevel = true,
UsePageLocksOnDequeue = true,
DisableGlobalLocks = true
}));
services.AddHangfireServer();
根据文档,Hangfire 1.7 有 built ib sql query
创建数据库。
我从文档中创建默认连接字符串:
"HangfireConnection": "Server=.\sqlexpress; Database=Hangfire; Integrated Security=SSPI;"
但是当我 运行 我的应用程序时,我得到这个错误:
System.Data.SqlClient.SqlException: 'Cannot open database "Hangfire" requested by the login. The login failed.
Login failed for user 'DESKTOP-FOVJ16Q\Michal'
我在 SQL Server Express 中的 Security
选项卡如下所示:
你能告诉我,我要检查什么才能与我的 SQL Server Express 建立连接吗?
EDIT1
我的 SQL Server Express "Security" 选项卡 Logins
:
我的 DESKTOP-FOVJ16Q\Micha
属性:
EDIT2
我现在检查了,从那个连接字符串:
"Server=.\SQLEXPRESS;Database=TaskManager;Trusted_Connection=True;"
我可以简单地在我的 SQL Express
中创建数据库并在 Management studio
中查看它
如果您阅读了您链接到的那个页面上的评论 (https://docs.hangfire.io/en/latest/configuration/using-sql-server.html),您会发现 "Fabian Schneiter" 提出了一个问题,他提出的问题与您提出的问题几乎相同 - 并得到了这个回应:
You need to create the database Hangfire
on your server first.. I understood, that hangfire will create the DB too, but that's wrong. If you have a Hangfire DB, Hangfire will create all needed tables..
所以我的建议是:尝试创建 Hangfire
数据库作为新数据库 - 然后 运行 再次编写您的代码,看看它是否有效
我正在尝试连接到 Hangfire service
中的 SQL Server Express。
我的 Startup.cs
中的代码如下所示:
services.AddHangfire(configuration => configuration
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UseSqlServerStorage(Configuration.GetConnectionString("HangfireConnection"), new SqlServerStorageOptions
{
CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
QueuePollInterval = TimeSpan.Zero,
UseRecommendedIsolationLevel = true,
UsePageLocksOnDequeue = true,
DisableGlobalLocks = true
}));
services.AddHangfireServer();
根据文档,Hangfire 1.7 有 built ib sql query
创建数据库。
我从文档中创建默认连接字符串:
"HangfireConnection": "Server=.\sqlexpress; Database=Hangfire; Integrated Security=SSPI;"
但是当我 运行 我的应用程序时,我得到这个错误:
System.Data.SqlClient.SqlException: 'Cannot open database "Hangfire" requested by the login. The login failed.
Login failed for user 'DESKTOP-FOVJ16Q\Michal'
我在 SQL Server Express 中的 Security
选项卡如下所示:
你能告诉我,我要检查什么才能与我的 SQL Server Express 建立连接吗?
EDIT1
我的 SQL Server Express "Security" 选项卡 Logins
:
我的 DESKTOP-FOVJ16Q\Micha
属性:
EDIT2
我现在检查了,从那个连接字符串:
"Server=.\SQLEXPRESS;Database=TaskManager;Trusted_Connection=True;"
我可以简单地在我的 SQL Express
中创建数据库并在 Management studio
如果您阅读了您链接到的那个页面上的评论 (https://docs.hangfire.io/en/latest/configuration/using-sql-server.html),您会发现 "Fabian Schneiter" 提出了一个问题,他提出的问题与您提出的问题几乎相同 - 并得到了这个回应:
You need to create the database
Hangfire
on your server first.. I understood, that hangfire will create the DB too, but that's wrong. If you have a Hangfire DB, Hangfire will create all needed tables..
所以我的建议是:尝试创建 Hangfire
数据库作为新数据库 - 然后 运行 再次编写您的代码,看看它是否有效