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

Ask A Question

Stats

  • Questions 162k
  • Answers 162k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The MFC _ConnectionPtr object has BeginTrans, CommitTrans and RollbackTrans methods.… May 12, 2026 at 12:05 pm
  • Editorial Team
    Editorial Team added an answer You want to call the Roles.GetRolesForUser method: Gets a list… May 12, 2026 at 12:05 pm
  • Editorial Team
    Editorial Team added an answer I found the solution. I created a forward lookup zone… May 12, 2026 at 12:05 pm

Related Questions

I want to create a convention for column names using Fluent NHibernate auto mapping.
Using fluent nhibernate, is it possible to map a private property in a base
I'm using Fluent NHibernate in order to auto map my entities. This is the
I am using Fluent NHibernate and having some issues getting a many to many
I consider fluent interfaces very convenient for many tasks. But I feel uneasy when

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.