1.右键项目创建一个xml配置文件:固定名字是:hibernate.cfg.xml
2配置文档网站:http://nhibernate.info/doc/tutorials/first-nh-app/your-first-nhibernate-based-application.html
hibernate.cfg.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.MySQL5Dialect</property> <property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property> <!--使用什么数据库--> <property name="connection.connection_string">Server=localhost;Database=mygamedb;User ID=root;Password=root;</property> <property name="show_sql">true</property> </session-factory> </hibernate-configuration>