Thommie
Thommie

Reputation: 67

FLuentNhibernate + Automapping

Anyone that can helt me with FluentNhibernate and automapping?

Check PotentialReasons collection, and InnerException for more detail. ----> FluentNHibernate.Cfg.FluentConfigurationException : An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail. ----> FluentNHibernate.Visitors.ValidationException : The entity 'NHibernateSessionManager' doesn't have an Id mapped. Use the Id method to map your identity property. For example: Id(x => x.Id).

i´m trying to automap from my classes and here is the code:

FluentConfiguration config = Fluently.Configure()
         .Database(MySQLConfiguration.Standard
         .ConnectionString(c => c
             .Server("127.0.0.1")
             .Database("db")
             .Username("root")
          .Password("pass")));

        _sessionFactory = config.Mappings(
                   m => m.AutoMappings.Add(AutoMap.AssemblyOf<Product>())
                   .ExportTo(@"c:\hbm\"))

                   .BuildSessionFactory();

Upvotes: 0

Views: 1577

Answers (1)

Firo
Firo

Reputation: 30803

AutoMap.AssemblyOf<Product>() tries to map all classes from the assembly.

Set a filer like AutoMap.AssemblyOf<Product>(t => t.Namespace.StartsWith(typeof(Product).Namespace))

Upvotes: 2

Related Questions