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

  • SEARCH
  • Home
  • 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 7013227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:21:33+00:00 2026-05-27T22:21:33+00:00

I’m setting up a new solution to map against SQL data that has been

  • 0

I’m setting up a new solution to map against SQL data that has been imported from an Access database. Auto Mappings work fine against the entities I have defined but I need to be able to use the Fluent mapping type to give access to the .NotFound.Ignore extension.

I have used exactly the same syntax in another project (I think!) which works fine. Have I made a schoolboy error to cause the “Unsupported mapping type ‘IT.Classes.Entities.Admin'”? Any help is much appreciated.

DDL:

CREATE TABLE [dbo].[Admin](
    [ID] [int] NOT NULL,
    [primaryEmail] [nvarchar](50) NULL,
    [secondaryEmail] [nvarchar](50) NULL,
    [highPriorityEmail] [nvarchar](50) NULL,
    [MobileEmail] [nvarchar](50) NULL,
    [EmailUser] [bit] NOT NULL,
    [HelpDeskMessage] [nvarchar](max) NULL
) ON [PRIMARY]

Entity:

namespace IT.Classes.Entities
{
    public class Admin
    {
    public virtual bool EmailUser { get; set; }

    public virtual string HelpdeskMessage { get; set; }

    public virtual string HighPriorityEmail { get; set; }

    public virtual int Id { get; set; }

    public virtual string MobileEmail { get; set; }

    public virtual string PrimaryEmail { get; set; }

    public virtual string SecondaryEmail { get; set; }
    }
}

Mapping:

using FluentNHibernate.Mapping;
using IT.Classes.Entities;

namespace IT.Classes.Mappings
{
    public sealed class AdminMap : ClassMap<Admin>
    {
        public AdminMap()
        {
            this.Id(x => x.Id);
            this.Map(x => x.EmailUser);
            this.Map(x => x.HelpdeskMessage);
            this.Map(x => x.HighPriorityEmail);
            this.Map(x => x.MobileEmail);
            this.Map(x => x.PrimaryEmail);
            this.Map(x => x.SecondaryEmail);
        }
    }
}

Session Factory:

private static ISessionFactory CreateItHelpdeskSessionFactory()
{
    return
        Fluently.Configure().Database(
            MsSqlConfiguration.MsSql2008.ConnectionString(
                ConfigurationManager.ConnectionStrings["ITHelpdesk"].ConnectionString))
                .Mappings(m => m.FluentMappings.Add<Admin>())
                .Mappings(m => m.FluentMappings.Add<Applications>())
                .Mappings(m => m.FluentMappings.Add<Category>())
                .Mappings(m => m.FluentMappings.Add<Log>())
                .Mappings(m => m.FluentMappings.Add<Multipliers>())
                .Mappings(m => m.FluentMappings.Add<Os>())
                .Mappings(m => m.FluentMappings.Add<Priority>())
                .Mappings(m => m.FluentMappings.Add<Request>())
                .Mappings(m => m.FluentMappings.Add<Status>())
                .BuildSessionFactory();
}

EDIT

I thought I would export the auto mappings to see if they would highlight a problem in my fluent mappings but they seem to be correct:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class xmlns="urn:nhibernate-mapping-2.2" name="IT.Classes.Entities.Admin, ITClasses, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" table="`Admin`">
    <id name="Id" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <column name="Id" />
      <generator class="identity" />
    </id>
    <property name="EmailUser" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <column name="EmailUser" />
    </property>
    <property name="HelpdeskMessage" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <column name="HelpdeskMessage" />
    </property>
    <property name="HighPriorityEmail" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <column name="HighPriorityEmail" />
    </property>
    <property name="MobileEmail" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <column name="MobileEmail" />
    </property>
    <property name="PrimaryEmail" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <column name="PrimaryEmail" />
    </property>
    <property name="SecondaryEmail" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <column name="SecondaryEmail" />
    </property>
  </class>
</hibernate-mapping>

EDIT 2

Full stack trace. Note potentialreasons = 0.

FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
 ---> FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.

 ---> System.InvalidOperationException: Unsupported mapping type 'IT.Classes.Entities.Admin'
   at FluentNHibernate.PersistenceModel.Add(Type type) in d:\Builds\FluentNH\src\FluentNHibernate\PersistenceModel.cs:line 152
   at FluentNHibernate.Cfg.FluentMappingsContainer.Apply(PersistenceModel model) in d:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentMappingsContainer.cs:line 127
   at FluentNHibernate.Cfg.MappingConfiguration.Apply(Configuration cfg) in d:\Builds\FluentNH\src\FluentNHibernate\Cfg\MappingConfiguration.cs:line 84
   at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration() in d:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 252
   --- End of inner exception stack trace ---
   at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration() in d:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 264
   at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in d:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 230
   --- End of inner exception stack trace ---
   at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in d:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 235
   at ConsoleChecker.Program.CreateItHelpdeskSessionFactory() in E:\code\code_testing\2010\ASPHelpdesks\ConsoleChecker\Program.cs:line 48
   at ConsoleChecker.Program.GetRequests() in E:\code\code_testing\2010\ASPHelpdesks\ConsoleChecker\Program.cs:line 40
   at ConsoleChecker.Program.Main(String[] args) in E:\code\code_testing\2010\ASPHelpdesks\ConsoleChecker\Program.cs:line 24
  • 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-27T22:21:34+00:00Added an answer on May 27, 2026 at 10:21 pm

    In your configuration code, the types mentioned in the Fluent Mappings should be the map classes, not the classes being mapped.

    That is, instead of:

    return
        Fluently.Configure().Database(
            MsSqlConfiguration.MsSql2008.ConnectionString(
                ConfigurationManager.ConnectionStrings["ITHelpdesk"].ConnectionString))
                .Mappings(m => m.FluentMappings.Add<Admin>())
                .Mappings(m => m.FluentMappings.Add<Applications>())
                .Mappings(m => m.FluentMappings.Add<Category>())
                .Mappings(m => m.FluentMappings.Add<Log>())
                .Mappings(m => m.FluentMappings.Add<Multipliers>())
                .Mappings(m => m.FluentMappings.Add<Os>())
                .Mappings(m => m.FluentMappings.Add<Priority>())
                .Mappings(m => m.FluentMappings.Add<Request>())
                .Mappings(m => m.FluentMappings.Add<Status>())
                .BuildSessionFactory();
    

    You need to say:

    return
        Fluently.Configure().Database(
            MsSqlConfiguration.MsSql2008.ConnectionString(
                ConfigurationManager.ConnectionStrings["ITHelpdesk"].ConnectionString))
                .Mappings(m => m.FluentMappings.Add<AdminMap>())
                .Mappings(m => m.FluentMappings.Add<ApplicationsMap>())
                .Mappings(m => m.FluentMappings.Add<CategoryMap>())
                .Mappings(m => m.FluentMappings.Add<LogMap>())
                .Mappings(m => m.FluentMappings.Add<MultipliersMap>())
                .Mappings(m => m.FluentMappings.Add<OsMap>())
                .Mappings(m => m.FluentMappings.Add<PriorityMap>())
                .Mappings(m => m.FluentMappings.Add<RequestMap>())
                .Mappings(m => m.FluentMappings.Add<StatusMap>())
                .BuildSessionFactory();
    

    Even better, to avoid having a separate line for every class map, use the .AddFromAssemblyOf<>() method, which uses reflection to add all class maps from a given assembly:

    return
        Fluently.Configure().Database(
            MsSqlConfiguration.MsSql2008.ConnectionString(
                ConfigurationManager.ConnectionStrings["ITHelpdesk"].ConnectionString))
                .Mappings(m => m.FluentMappings.AddFromAssemblyOf<AdminMap>())
                .BuildSessionFactory();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into

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.