NHibernate BuildSessionFactory()ArgumentException:不支持关键字:'初始目录'

时间:2014-05-27 16:18:38

标签: c# asp.net-mvc nhibernate

我正在构建一个ASP.NET MVC项目,并且正在使用NHibernate而不是Entity Framework。

遇到的问题是我收到了ArgumentException:不支持关键字:'初始目录'在Configuration对象中调用BuildSessionFactory()方法时。

config = new Configuration();
config.Configure();
sessionFactory = config.BuildSessionFactory();
session = sessionFactory.OpenSession();

IList<Catalogue> catalogues = (from c in session.Query<Catalogue>()
                               select c).ToList();

return this.Json(catalogues, JsonRequestBehavior.AllowGet);

我的连接字符串是

<property name="connection.connection_string">Data Source=.\SQLEXPRESS;Initial Catalog=Passion4Performance;Integrated Security=True</property>

我尝试了很多解决方案,但似乎没有解决这个问题。 提前谢谢。

1 个答案:

答案 0 :(得分:0)

您的配置文件应如下所示:

<connectionStrings>
    <add name="NameOfConnectionString" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=Passion4Performance;Integrated Security=True" />
</connectionStrings>

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
        <property name="connection.connection_string_name">NameOfConnectionString</property>
    </session-factory>
</hibernate-configuration>
相关问题