I have a *ASP.NET MVC 4* application. It uses *Spring.net* and *Nhibernate 
3.2*. Configurations are done by xml files.

Recently I got into Nhibernate's *Mapping by code* new feature. I'm trying 
to implement it in my current application, so ClassMapping's will be 
configured and scheme will be updated according to that.

I couldn't achieve this, making some changes in my xml configurations.

Here's my *NHibernate* configuration

<object id="NHibernateSessionFactory" 
type="Spring.Data.NHibernate.LocalSessionFactoryObject, 
Spring.Data.NHibernate32">
    <property name="MappingAssemblies">
      <list>
        <value>CM.Data.NHibernate</value>
      </list>
    </property>
    <property name="DbProvider" ref="DbProvider"/>

    <property name="HibernateProperties">
      <dictionary>
        <entry key="hibernate.connection.provider" 
value="NHibernate.Connection.DriverConnectionProvider"/>
        <entry key="dialect" value="NHibernate.Dialect.MsSql2008Dialect"/>
        <entry key="connection.driver_class" 
value="NHibernate.Driver.SqlClientDriver"/>
        <entry key="hbm2ddl.auto" value="update"/>
        <entry key="hbm2ddl.keywords" value="auto-quote"/>
        <entry key="show_sql" value="true"/>
        <entry key="adonet.batch_size" value="0"/>
        <entry key="hibernate.current_session_context_class" 
value="Spring.Data.NHibernate.SpringSessionContext, Spring.Data.NHibernate32"/>
      </dictionary>
    </property>
    <property name="ExposeTransactionAwareSessionFactory" value="true" />
  </object>

*Sample mapping class*

namespace CM.Data.NHibernate{
    public class DynamicEntityMap : ClassMapping<DynamicEntity>
    {
        public DynamicEntityMap()
        {
            Id(x => x.Id);
        }
    }

    public class DynamicEntity
    {
        public virtual int Id { get; set; }
    }}

It doesn't seem to work. Table is not generated.

Am I missing something? I was thinking to override 
LocalSessionFactoryObject as it was done for FNH in the link below. Would 
it work for me also? I'm not sure if it won't break transaction management 
or something else.

Please, give me some insights on this matter.

What's the best approach in this situation?

Using Fluent NHibernate in 
Spring.Net<http://blog.bennymichielsen.be/2009/01/04/using-fluent-nhibernate-in-spring-net/>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to