Nhibernate 配置文件问题

stg609 stg609 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我在项目中使用app.config来配置nhibernate时测试正常
其中内容为:

<?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

不知是何故,请大家帮忙。
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
stg609
.NET社区 62,272 成员 668,968 内容