Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 356153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:05:06+00:00 2026-05-12T12:05:06+00:00

When using fluent configuration to specify fluent mappings like this: .Mappings(m => m.FluentMappings.AddFromAssembly(typeof(UserMapping).Assembly)) At

  • 0

When using fluent configuration to specify fluent mappings like this:

.Mappings(m => m.FluentMappings.AddFromAssembly(typeof(UserMapping).Assembly))

At the moment I am getting a “NHibernate.MappingException : No persister for” error.

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)

Thanks!

UPDATE:

Sorry for not responding to answers very quickly – I had to travel unexpectedly after setting the bounty.

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:

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 receive this exception when trying to run a test in nunit that makes use of a repository using this session mechanism:

NHibernate.MappingException : No persister for: xxxx.Model.Entities.User

Thanks

P.S.:
I’ve tried using both and in AddFromAssemblyOf();
Project with mapping definitions (DataAccess) has reference to project with entities (Model).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T12:05:06+00:00Added an answer on May 12, 2026 at 12:05 pm

    What version of Fluent NHibernate are you using? There have been problems with the release candidate and the 1.0 release versions. You may want to consider downloading the latest version from the SVN repository.

    http://fluent-nhibernate.googlecode.com/svn/trunk/

    Additionally, you may want to check the connection string to make sure that it is completely correct, and you want to make sure that “User” below points to a class.

    .Mappings(m => m.FluentMappings.AddFromAssemblyOf<User>())
    

    Also, I should mention that when you use AddFromAssemblyOf, fluent will try to map EVERY class in that assembly. If you have any other classes in that namespace you will want to filter them. There are several different ways to accomplish this. The simplest way is to just place all of the POCOs you want to map in their own namespace and then do something like the following.

    .Mappings(m => m.AutoMappings
                    .Add(AutoMap.AssemblyOf<MyNamespace.Entities.MyClass>()
                    .Where(type => type.Namespace == "MyNamespace.Entities")
    

    The Where clause will filter items you don’t want mapped.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Fluent NHibernate and having some issues getting a many to many
Is there a way to setup SQLite connection pooling using Fluent NHibernate configuration? E.g.
I am using Fluent NHibernate with an external 'hibernate.cfg.xml' file. Following is the configuration
Is it possible to map an enum as a string using Fluent Nhibernate?
I'm using NHibernate and Fluent NHibernate to create a mapping file for a domain
I've just started using NHibernate and fluent-NHibernate which I think is great. I've been
I'm enjoying using Fluent NHibernate with AutoMappings but every now and then I get
I have been unable to persist a nullable enum using NHibernate with Fluent NHibernate
I have a WPF application running with VS2010 .Net3.5 using Nhibernate with FluentNHibernate +
I'm very interested in using NHibernate.Burrow for my session handling and DAO in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.