Rituraj Mishra
Rituraj Mishra

Reputation: 141

Getting NHibernate.Cfg.HibernateConfigException

{"An exception occurred parsing configuration :The 'name' attribute is invalid - The value 'hbm.ddl.auto' is invalid according to its datatype 'String' - The Enumeration constraint failed."}

I am getting this exception with respect to my config.hbm file cant understand why even if I am not using any name property in the config.hbm.As I am a newbie to nhibernate so cant understand wht the problem is.I am posting the Hibernate configuration file here

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration  xmlns="urn:nhibernate-configuration-2.2" >
  <session-factory name="NHibernate.Test">
    <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
    <property name="connection.connection_string">Data Source=KNS009-PC;Initial Catalog=WomensCare;Integrated Security=True</property>
    <property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
    <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
    <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
    <property name="current_session_context_class">NHibernate.Context.ThreadLocalSessionContext</property>
    <property name="hbm.ddl.auto">update</property>

  </session-factory>
</hibernate-configuration>

Upvotes: 1

Views: 1801

Answers (1)

Sample NHibernate configuration file

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2-x-factories">

<session-factory name="Development">
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
    <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
    <property name="connection.connection_string">Server=dsql01;DataBase=dbDev;uid=nhDeveloper;pwd=pass1234</property>

    <property name="show_sql">true</property>

    <mapping assembly="DataLayer" />
</session-factory>

<session-factory name="Production">
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
    <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
    <property name="connection.connection_string">Server=psql02;DataBase=dbDev;uid=nhDeveloper;pwd=pass5678</property>

    <property name="show_sql">false</property>

    <mapping assembly="DataLayer" />
</session-factory>

</hibernate-configuration>

Upvotes: 1

Related Questions