Note that there are some explanatory texts on larger screens.

plurals
  1. POFluent mapping - entities and classmaps in different assemblies
    primarykey
    data
    text
    <p>When using fluent configuration to specify fluent mappings like this:</p> <pre><code>.Mappings(m =&gt; m.FluentMappings.AddFromAssembly(typeof(UserMapping).Assembly)) </code></pre> <p>At the moment I am getting a "NHibernate.MappingException : No persister for" error.</p> <p>Is it a problem that my Entities and my ClassMaps are in different assemblies? Presumably AddFromAssembly is interested in the assembly that holds the class maps, not the entities? (that is what I have assumed)</p> <p>Thanks!</p> <h2>UPDATE:</h2> <p>Sorry for not responding to answers very quickly - I had to travel unexpectedly after setting the bounty.</p> <p>Anyway, thanks for the responses. I've taken a look through them and have updated my code to use AddFromAssemblyOf rather than AddFromAssembly, but still am getting the same error. Possibly I am doing something stupid. Here is the full code for the session factory code I am using:</p> <pre><code>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 =&gt; m.FluentMappings.AddFromAssemblyOf&lt;User&gt;()) .BuildSessionFactory(); } return _sessionFactory; } } public static ISession OpenSession() { return SessionFactory.OpenSession(); } } </code></pre> <p>I receive this exception when trying to run a test in nunit that makes use of a repository using this session mechanism:</p> <p>NHibernate.MappingException : No persister for: xxxx.Model.Entities.User</p> <p>Thanks</p> <p>P.S.: I've tried using both and in AddFromAssemblyOf(); Project with mapping definitions (DataAccess) has reference to project with entities (Model).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload