This project is read-only.

Association references unmapped class


I created a MVC5/WebApi 2 web application using the default Visual Studio 2013 template. I created an (empty) ApplicationUser class and its mappings:
public class ApplicationUser : IdentityUser
        public virtual async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
            // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
            var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
            // Add custom user claims here
            return userIdentity;

    public class ApplicationUserMappings : IdentityUserMap<ApplicationUser>
        public ApplicationUserMappings()

However when I reach my SessionFactory, I get an error message:
Association references unmapped class: NHibernate.Identity.IdentityUserClaim
Not sure why that class would be unmapped, since looking at the source code the Fluent Mappings are in Hibernate.Identity.Internal.Mapping.IdentityUserClaimMap().

This is my session factory (I commented out the mappings of my own lib for troubleshooting):
public static FluentConfiguration GetConfiguration()
            if (configuration == null)
                configuration = Fluently.Configure()
                                    .ConnectionString(c => c.FromConnectionStringWithKey("Ribandelle")
                                .Mappings(m => m.FluentMappings.AddFromAssemblyOf<ApplicationUser>())
                                /*.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Album>())*/;
            return configuration;
Not sure what's happening here!


EnricoGallus wrote Dec 21, 2016 at 3:15 AM

The issue is over two years old, sorry, just started to participate this small project, because i really like it :)

I guess you already have found another solution or are using another framework, will just answer it to help others who probably will stumble over this.

The Problem probably is due to the way you are adding your mappings to the configuration.
You are adding assemblies to your mappings where the following classes are defined:
  • ApplicationUser
  • Album
i would guess that both classes are defined in the same assembly in your mvc project, right?
Could you try to add the NHibernate.Identity assembly to the mapping as well?
This should add the mapping of NHibernate.Identity.Internal.Mapping and the error should not occur anymore.

Please let me know if you still have trouble.