Nhibernate 配置文件问题
我在项目中使用app.config来配置nhibernate时测试正常
其中内容为:
但是我看见很多直接使用的是"hibernate.cfg.xml"文件而不是app.config
于是我把app.config文件修改成hibernate.cfg.xml,并且也已经把该文件的输出选项设置为了“始终复制”
结果测试的时候一直显示的是:
NhibernateSample.Test.LeaveMessageDALTest.InsertTest:
NHibernate.MappingException : Could not compile the mapping document: NhibernateSample.Model.HbmMaps.Users.hbm.xml
----> System.InvalidOperationException : Could not find the dialect in the configuration
不知是何故,请大家帮忙。
其中内容为:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
</configSections>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">Data Source=1AC425E4D0B74F1;Initial Catalog=GuestBook;User ID=sa;Password=1</property>
<mapping assembly="NhibernateSample.Model"/>
</session-factory>
</hibernate-configuration>
</configuration>
但是我看见很多直接使用的是"hibernate.cfg.xml"文件而不是app.config
于是我把app.config文件修改成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.MsSql2005Dialect</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">Data Source=1AC425E4D0B74F1;Initial Catalog=GuestBook;User ID=sa;Password=1</property>
<mapping assembly="NhibernateSample.Model"/>
</session-factory>
</hibernate-configuration>
结果测试的时候一直显示的是:
NhibernateSample.Test.LeaveMessageDALTest.InsertTest:
NHibernate.MappingException : Could not compile the mapping document: NhibernateSample.Model.HbmMaps.Users.hbm.xml
----> System.InvalidOperationException : Could not find the dialect in the configuration
不知是何故,请大家帮忙。
...全文
相关推荐
NHibernate学习笔记
- **配置问题**:在进行一对多映射时,常见的问题是未能正确配置NHibernate的XML映射文件。例如,配置文件可能需要指向资源库中的“嵌入资源”而不是直接的文件路径。
NHibernate 连接oralce 源码
在连接Oracle数据库时,我们需要在NHibernate配置文件中指定Oracle的数据提供者。
NHibernate3.2
综合以上信息,学习和使用NHibernate3.2涉及的关键知识点包括:- 对象关系映射(ORM)的概念和原理。- NHibernate的安装和配置,包括XML配置文件的编写。
放于VS 下睥NHibernate感应文档
**错误排查与调试**:提供在VS环境下遇到问题时的解决策略,如何使用NHibernate的日志功能进行问题定位。9.
NHibernate-3.3.3.GA 官方包
它是 NHibernate 的核心配置文件,定义了数据库连接、实体映射、缓存策略等。


