Free nHibernate configuration

I am trying to set up free nHibernate and have this code

Assembly mappingAssembly = Assembly.ReflectionOnlyLoadFrom("LibrarySample.Model.dll");
sessionFactory = Fluently.Configure()
  .Database(MsSqlConfiguration.MsSql2005
     .ConnectionString(c => c
        .FromAppSetting("ConnectionString"))
     .ShowSql())
   .Mappings(m => m
     .FluentMappings.AddFromAssembly(mappingAssembly))
   .BuildSessionFactory();

When I start, I get this message, although "FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used to create the SessionFactory."

If I use this code, it works, but I do not want to reference the model assembly directly from the Core assembly, which has an nHibernate session manager.

sessionFactory = Fluently.Configure()
  .Database(MsSqlConfiguration.MsSql2005
     .ConnectionString(c => c
        .FromAppSetting("ConnectionString"))
     .ShowSql())
   .Mappings(m => m
     .FluentMappings.AddFromAssemblyOf<LibrarySample.Model.Book>())
   .BuildSessionFactory();

Can anyone help?

+3
source share
1 answer

I did it. One of the properties of the Entity class was not marked as virtual.

+8
source

Source: https://habr.com/ru/post/1704306/


All Articles