我正在尝试NHibernate,一开始我得到了:
System.InvalidOperationException:实例失败。
at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo,SqlInternalConnectionTds connHandler,Boolean ignoreSniOpenTimeout,Int64 timerExpire,Boolean encrypt,Boolean trustServerCert,Boolean integratedSecurity,Boolean withFailover,Boolean isFirstTransparentAttempt,SqlAuthenticationMethod authType)
... 在System.Data.SqlClient.SqlConnection.Open()
在NHibernate.Connection.DriverConnectionProvider.GetConnection()
... 在NHibernate.Cfg.Configuration.BuildSessionFactory()
在NHibernateDemo.Program.Main(String [] args)
配置为:
<hibernate-configuration xmlns = "urn:nhibernate-configuration-2.2">
<session-factory>
<property name = "connection.connection_string">
Data Source=localhost\\SQLEXPRESS;Initial Catalog=NHibernateDemoDB;Integrated Security=SSPI
</property>
<property name = "connection.driver_class">
NHibernate.Driver.SqlClientDriver
</property>
<property name = "dialect">
NHibernate.Dialect.MsSql2012Dialect
</property>
<mapping assembly = "NHibernateDemo"/>
</session-factory>
</hibernate-configuration>
代码是:
static void Main(string[] args)
{
var cfg = new NHibernate.Cfg.Configuration();
cfg.Configure();
var sessionFactory = cfg.BuildSessionFactory();
Console.ReadLine();
}
我该如何解决?
也许SQL Server中存在问题?
答案 0 :(得分:1)