views:

220

answers:

1

I'm trying to utilise FluentNHibernate with Automapping but am receiving the following error

  No persister for: nHibernateSpike.Entities.Route
    NHibernate.MappingException: No persister for: nHibernateSpike.Entities.Route

Here's the relevant stuff;

        var model = AutoMap.AssemblyOf<Route>().
            Where(t => t.Namespace == "nHibernateSpike.Entities");

        model.WriteMappingsTo(@"c:\hbm");

        var db = MsSqlConfiguration.MsSql2008
            .ConnectionString(c => c
            .Server("localhost")
            .Database("PTSIntegrationDB")
            .TrustedConnection()
            )
            .ShowSql();

        var sessionFactory = Fluently.Configure()
            .Database( db )
            //.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Route>())
            .Mappings(m => m.AutoMappings.Add(model))
            .BuildSessionFactory();

        return sessionFactory;

Entity

        namespace nHibernateSpike.Entities
        {
            public class Route
            {
                public virtual int Id { get; private set; }
                public virtual string Number { get; set; }
                public virtual string ConfirmationCategory { get; set; }

                public Route() { }

            }
        }

I'm pulling my hair out. Using the following ClassMap works;

        public class RouteMap: ClassMap<Route>
        {
            public RouteMap()
            {
                Table("Route");
                Id(c => c.Id);
                Map(c => c.Number);
                Map(c => c.ConfirmationCategory);
            }

        }

I have the opportunity to use AutoMap to drive the DB oon this project, and I'd like to use it - any clues?

+1  A: 

I seem to recall there's an outstanding bug where calling WriteMappingsTo can prevent your mappings from being passed through to NHibernate, try removing that call and seeing what happens.

James Gregory
Bingo :) Many thanks - http://code.google.com/p/fluent-nhibernate/issues/detail?id=325
Jason Hyland