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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:00:13+00:00 2026-05-30T04:00:13+00:00

Fluent Nhibernate Many to Many association to multiple classes We use Nhibernate and up

  • 0

Fluent Nhibernate Many to Many association to multiple classes
We use Nhibernate and up to now we have been able use the auto mapping. But I think this is about to change.
We have a Code class that has a many to many relation with several other classes.
I’m thinking something along these lines:

public class Code
{
    public virtual Guid Id { get; set; }
    public virtual ICollection<CodeUsage> Usage { get; set; }
}

class CodeUsage
{
    public virtual Guid Id { get; set; }
    public virtual Code Code { get; set; }

    // Class, [Property,] Id for "ANY" mapping to A & B
}

class A 
{
    public virtual Guid Id { get; set; }
    public virtual ICollection<CodeUsage> Codes { get; set; }
}

class B 
{
    public virtual Guid Id { get; set; }
    public virtual ICollection<CodeUsage> Codes { get; set; }
}

Many to Many will lead to the creation of a linking table, in the linking table their needs come a mapping to the classes using codes. In the documentation it is referred to as a “Any” mapping.
But I have no idea how get fluent to create one.

Thoughts anyone? or even better: a solution <);o)}{

  • 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-30T04:00:15+00:00Added an answer on May 30, 2026 at 4:00 am

    You can’t map <many-to-any> in Fluent NHibernate – it’s not supported.

    I think it may be a good reason to move to mapping-by-code, that supports it well.

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

Sidebar

Related Questions

I'm using Fluent NHibernate, and auto-mapping the classes. I have a computed property in
I have 3 classes that I'm trying to map using fluent nHibernate, but I've
I'm using Fluent NHibernate auto mapping. I need to access more than one database
I'm learning Fluent NHibernate (and by extension, NHibernate generally). I'm using auto-mapping with some
Using Nhibernate and Fluent NHibernate for the mapping, I have a parent entity with
I said Fluent NHibernate in the subject, but I think this is an NHibernate
Is there a way to use Rhino.Commons with Fluent Nhibernate, (in particular AutoMapping)? Many
I had a similar question to Fluent NHibernate: How to create one-to-many bidirectional mapping?
I am getting NHibernate.MappingException while trying to do one-to-many mapping in fluent nhibernate. Below
I am using NHibernate and have a many-to-many association between an Employee and a

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.