尝试使用 NHibernate 连接到我的数据库时出现登录失败错误:
var config = Fluently.Configure()
.Database(MsSqlConfiguration
.MsSql2005
.ConnectionString("Data Source=SERVER1\\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=xxx"))
.Mappings(x => x.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly()));
在Error 18456 State 5
SQL Management Studio 的日志查看器中。
但是使用sqlcmd
或 Management Studio 可以正常工作(使用 Windows Auth)!
可能是什么问题呢?
编辑 NHibernate 异常:
Test method ProjektLogg.Tests.NHibernateTests.ShouldBeAbleToGenerateFactory threw exception:
FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
---> NHibernate.HibernateException: Login failed for user XXX-INTRANET\username. ---> System.Data.SqlClient.SqlException: Login failed for user XXX-INTRANET\username.