简体   繁体   English

C#nHibernate与Postgres数据库连接字符串

[英]c# nHibernate with Postgres db connection string

I'm using NHibernate for the Data Access Layer (DAL) in ac# solution. 我在ac#解决方案中将NHibernate用于数据访问层(DAL)。 Note, I've used Hibernate and NHibernate successfully in many instances, but this is the first time with a Postgres DB. 注意,我已经在许多实例中成功使用了Hibernate和NHibernate,但这是Postgres DB的第一次。 Below is my NHibernate configuration XML file and the associated sessionBuilder. 以下是我的NHibernate配置XML文件和关联的sessionBuilder。 I'm getting the following error, which is raised on the BuildSessionFactory() method call. 我收到以下错误,该错误在BuildSessionFactory()方法调用上引发。 I've tried a hundred variations of the connection string, to no avail. 我尝试了一百种连接字符串的变体,但都没有用。 Any ideas where I'm wrong here? 有什么想法我错了吗?

[ArgumentException: key=value argument incorrect in ConnectionString 
Parameter name: data source]

Here is the XML config: 这是XML配置:

<?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="dialect">NHibernate.Dialect.PostgreSQLDialect</property>
        <property name="connection.driver_class">NHibernate.Driver.NpgsqlDriver</property>
        <property name="connection.connection_string_name">server=1.1.1.1;port=8060;database=workgroup;user id=tab;password=***;</property>
<property name="current_session_context_class">web</property>
<mapping assembly="ClientAnalyticsDashboard"/>
</session-factory>
</hibernate-configuration>

Here is the code (error occurs on the last line shown): 这是代码(错误发生在显示的最后一行):

Configuration configuration = new Configuration();
configuration.AddAssembly(Assembly.GetCallingAssembly());
configuration.Proxy(p => { p.Validation = false; });
TabSessionFactory = configuration.BuildSessionFactory();

我认为您需要将connection.connection_string_name更改为connection.connection_string

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM