When using a free configuration to specify smooth mappings, such as:
.Mappings(m => m.FluentMappings.AddFromAssembly(typeof(UserMapping).Assembly))
I am currently receiving the error message "NHibernate.MappingException: No persister for".
Is there a problem that my objects and my ClassMaps are in different assemblies? Suppose AddFromAssembly is interested in an assembly that contains class maps, not entities? (this is what I assumed)
Thanks!
UPDATE:
Sorry for not responding very quickly - I had to travel unexpectedly after setting up the award.
Anyway, thanks for the answers. I looked through them and updated my code to use AddFromAssemblyOf instead of AddFromAssembly, but still getting the same error. Maybe I'm doing something stupid. Here is the complete code for the factory session that I am using:
public class NHibernateHelper
{
private static ISessionFactory _sessionFactory;
private static ISessionFactory SessionFactory
{
get
{
if (_sessionFactory == null)
{
var mysqlConfig = FluentNHibernate.Cfg.Db.MySQLConfiguration
.Standard
.ConnectionString("CONNECTION STRING OMITTED")
.UseOuterJoin()
.ProxyFactoryFactory("NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle");
_sessionFactory = FluentNHibernate.Cfg.Fluently.Configure()
.Database(mysqlConfig)
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<User>())
.BuildSessionFactory();
}
return _sessionFactory;
}
}
public static ISession OpenSession()
{
return SessionFactory.OpenSession();
}
}
I get this exception when trying to run a test on nunit, which uses the repository using this session mechanism:
NHibernate.MappingException: no persister for: xxxx.Model.Entities.User
thanks
PS: I tried using both in AddFromAssemblyOf (); A project with mapping definitions (DataAccess) has a link to a project with entities (Model).
source
share