我有一个简单的集成完整性测试来证明我的映射工作正常,最初我使用的是 MsSQL 数据库服务器,但现在已经添加了对 MySQL 的支持(或者至少我认为我有),但是每当我遇到以下错误时加载 nhibernate.cfg.xml 文件。
SetUp:System.ArgumentNullException:值不能为空。
参数名称:流
这是配置文件:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<!-- Connection config -->
<property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.MySQLDialect</property>
<property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
<property name="connection.connection_string">Server=localhost;Database=xxxxx;User ID=root;</property>
<property name="show_sql">true</property>
<!-- Mapping config -->
<mapping assembly="xxxxx.xxxxx"/>
</session-factory>
</hibernate-configuration>
互联网似乎有一些关于这是 MySQL 连接器问题的信息,但仅限于 6.1 之前的版本,并且我没有找到解决方案,只是人们说要更新。但是我在最新版本。任何帮助都会很棒!
** 编辑 **
这是堆栈跟踪,以帮助诊断潜在问题:
at System.IO.StreamReader..ctor(Stream stream, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
at System.IO.StreamReader..ctor(Stream stream)
at MySql.Data.MySqlClient.SchemaProvider.GetReservedWords()
at MySql.Data.MySqlClient.SchemaProvider.GetSchemaInternal(String collection, String[] restrictions)
at MySql.Data.MySqlClient.ISSchemaProvider.GetSchemaInternal(String collection, String[] restrictions)
at MySql.Data.MySqlClient.SchemaProvider.GetSchema(String collection, String[] restrictions)
at MySql.Data.MySqlClient.MySqlConnection.GetSchema(String collectionName, String[] restrictionValues)
at MySql.Data.MySqlClient.MySqlConnection.GetSchema(String collectionName)
at NHibernate.Dialect.Schema.AbstractDataBaseSchema.GetReservedWords()
at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.GetReservedWords(Dialect dialect, IConnectionHelper connectionHelper)
at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update(ISessionFactory sessionFactory)
at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners)
at NHibernate.Cfg.Configuration.BuildSessionFactory()
at xxxxx.unittests.logic.mappings.MappingSanityTests.PreTestSetup() in C:\Documents and Settings\xxxxx\My Documents\Projects\Other\xxxxx\src\tests\xxxxx.integrationtests\logic\mappings\MappingSanityTests.cs:line 22