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 4081370
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:03:07+00:00 2026-05-20T18:03:07+00:00

I am getting NHibernate.MappingException while trying to do one-to-many mapping in fluent nhibernate. Below

  • 0

I am getting NHibernate.MappingException while trying to do one-to-many mapping in fluent nhibernate.
Below are the snippets from my entity and their mapping classes:

public class ReportRequest : IReportRequestToBeFullyLoaded
{
    public virtual Int32? Id { get; set; }
    public virtual string Description { get; set; }
    public virtual ISet<ReportOutputEmail> ReportOutputEmails { get; set; }
}

public class ReportOutputEmail
{
    public virtual string RecipientAddress { get; set; }
    public virtual string Message { get; set; }
    public virtual ReportRequest ReportRequest { get; set; }
}

public class ReportRequestMap : ClassMap<ReportRequest>
{
    public ReportRequestMap()
    {
        Table("ReportRequest");
        Id(x => x.Id).UnsavedValue(null).GeneratedBy.Native();
        Map(x => x.Description);
        HasMany(x => x.ReportOutputEmails).Table("ReportOutputEmail")
            .ForeignKeyConstraintName("FK_ReportOutputEmail_ReportRequest")
            .KeyColumn("ReportRequestId")
            .AsSet()
            .Inverse()
            .Cascade.AllDeleteOrphan();
    }
}

public class ReportOutputEmailMap: ClassMap<ReportOutputEmail>
{
    public ReportOutputEmailMap()
    {
        References(x => x.ReportRequest)
            .ForeignKey("FK_ReportOutputEmail_ReportRequest")
            .Column("ReportRequestId");
        Map(x => x.RecipientAddress);
        Map(x => x.Message);
    }
}

There is some issue with one-to-many mapping between ReportRequest->ReportOutputEmail,
Getting error:

Error: NHibernate.MappingException: (XmlDocument)(3,6): XML validation error: The  
element 'class' in namespace 'urn:nhibernate-mapping-2.2' has invalid child element  
'property' in namespace 'urn:nhibernate-mapping-2.2'. List of possible elements  expected:  'meta, subselect, cache, synchronize, comment, tuplizer, id, composite-id' in     namespace  'urn:nhibernate-mapping-2.2'.

Can anyone help figuring out.

Thank you!

  • 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-20T18:03:08+00:00Added an answer on May 20, 2026 at 6:03 pm

    Your ReportOutputEmail doesn’t have an identity, it’ll need one if its going to be an entity.

    Also, I recommend you upgrade your copy of Fluent NHibernate, as this is reported in a much more helpful manner since 1.1 (you’d get an identity missing message).

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

Sidebar

Related Questions

I am getting this exception when mapping one-to-many relation. my mapping xml looks like
Ok so I 'm just getting into nhibernate (using fluent). One thing that I
I'm getting a mapping error in Fluent NHibernate. Why is it still looking for
hiii i am getting this error while running test for my fluent nhibernate application.
I am using Fluent NHibernate and having some issues getting a many to many
Background: I'm getting a mapping failure when trying to use nHibernate. The application consists
I am successfully getting Fluent NHibernate to update my database by calling UpdateBaseFiles: Public
I'm just getting started with NHibernate and reading blogs and articles from all over.
Just getting my feet wet with some Fluent NHibernate AutoMap conventions, and ran into
I am getting the folloinwg error from NHibernate: System.ObjectDisposedException: Session is closed! Object name:

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.