3

I am trying to configure fluent 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 run I get this message though "FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory".

If I use this code it works, but I don't want to reference the Model assembly directly from the Core assembly that has the 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 someone help?

1 Answer 1

8

I worked it out. One of the properties in the Entity class was not marked as virtual.

Sign up to request clarification or add additional context in comments.

1 Comment

Didn't understand, why? Isn't making properties virtual enough?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.