ISessionFactory sessionFactory =
new Configuration().Configure().BuildSessionFactory();
var session = sessionFactory.GetCurrentSession();
在该代码中,它抛出错误消息“No CurrentSessionContext configured(设置属性current_session_context_class)!”
关于nhibernate的app.config如下:
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="dialect">NHibernate.Dialect.MySQL5Dialect</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.connection_string">
Server=localhost;initial catalog=test;uid=root;pwd=root123
</property>
<property name="current_session_context_class">thread</property>
<mapping assembly="testNH" />
</session-factory>
我的错误在哪里?以及如何修改代码?