tags:

views:

24

answers:

1

I am having the error message with MappingNHibernateException:

{"Could not compile the mapping document: Infrastructure.DataAccess.Mappings.Post.hbm.xml"}

Could not find the dialect in the configuration

on the part

  Configuration configuration = new Configuration()
                .AddAssembly("Infrastructure");
                _sessionFactory = configuration.BuildSessionFactory();

What is wrong?


hibernate.cfg.xml

    <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>    
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver </property>
    <property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
    <property name="connection.connection_string">Server=localhost\SQLServer2005;database=NHibernate101;Integrated Security=True;</property>
    <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
    <mapping assembly="Infrastructure"></mapping>
  </session-factory>
</hibernate-configuration>
A: 

Try this. In app.config file:

<configuration>
  <configSections>
    <section
        name="hibernate-configuration"
        type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"
        />
  </configSections>

  <!-- Replace with your values -->
  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
      <property name="dialect">NHibernate.Dialect.SQLiteDialect</property>
      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="connection.connection_string">Data Source=data.db3;Version=3</property>
      <property name="connection.driver_class">NHibernate.Driver.SQLite20Driver, NHibernate</property>
      <property name="show_sql">true</property>
      <property name="adonet.batch_size">0</property>
      <property name="default_batch_fetch_size">0</property>

      <mapping assembly="Infrastructure" />
    </session-factory>
  </hibernate-configuration>

</configuration>

And in your code:

var cfg = new Configuration().Configure();
var factory = cfg.BuildSessionFactory();
Darin Dimitrov
I am using a hibernate.cfg.xml file and in the file I have ...look in the edited part...Do I need to do something else?