I encountered an issue:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details. )
it seems that I cannot connect to my local database which is configured in my nhibernate.xml
. the same connection string is working when using other forms of connection (ADO.net, EntityFrameWork). Am I missing something here?
here is my xml file:
<?xml version='1.0' encoding='utf-8'?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">Server=(localdb)\mssqllocaldb;Database=my_database;Trusted_Connection=True;MultipleActiveResultSets=true</property>
<property name="show_sql">true</property>
<property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
</session-factory>
</hibernate-configuration>
I already tried changing the backslashes to double, removing the localdb, and any other combinations of the connection string.
1条答案
按热度按时间tktrz96b1#
I manage to fix this issue. Apparently. nhibernate doesn't accept the usual connection string keywords. What I did is use the Named Pipe. Here's what I did
SqlLocalDB.exe info
SqlLocalDB.exe info MyInstance
If Instance pipe name is blank, make sure your server is running and try connecting to your server via SQL.