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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:45:00+00:00 2026-06-02T19:45:00+00:00

I have two classes that I’m trying to map in Loquacious Nhibernate. The mapping

  • 0

I have two classes that I’m trying to map in Loquacious Nhibernate.

The mapping is like the following

  public class FooMap : ClassMapping<Foo>
  {
    Table("FooTableName");
    ComposedId(compIDMapper =>
      {
        compIDMapper.Property(x => x.SomeInt, m => m.Column("SomeInt"));
        compIDMapper.ManyToOne(x => x.SomeReference, m => m.Column("SomeReference"));
      });
  }

  public class BarMap : ClassMapping<Bar>
  {
    Table("BarTableName");
    Id(x => x.ID, m => m.Column("barID"));

    ManyToOne(x => x.Foo, m => m.Columns( columnMapper =>
                                                             {
                                                               columnMapper.Name("SomeIntID"); //Both of these columns are in the BarTableName like they should be
                                                               columnMapper.Name("SomeReferenceID");
                                                             }));
  }

But when the mappings are being built I get the following error:

Foreign key (FK554EAF2427B2CA28:BarTableName[SomeIntID])) must have same number of columns as the refe,renced primary key (FooTableName[SomeInt, SomeReference])

I’m not sure what I’m doing wrong, it looks like it should work, but I’ve been banging my head on this for awhile now and haven’t gotten anywhere. Any ideas on what I’m doing wrong?

  • 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-06-02T19:45:01+00:00Added an answer on June 2, 2026 at 7:45 pm

    Finally figured this out, posting this for anyone else who comes along.

    My problem was misunderstanding the columns mapper. What it is supposed to be is the following:

    ManyToOne(x => x.Foo, m => m.Columns(new Action<IColumnMapper>[]
                                                                    {
                                                                      colMapper => colMapper.Name("SomeIntID"),
                                                                      colMapper => colMapper.Name("SomeReferenceID")
                                                                    }));
    

    This solved the issue. Should have noticed it when I looked at the function signature, but I completely missed it.

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

Sidebar

Related Questions

Let's say I have two classes that look like this: public class ByteFilter {
In nhibernate, I have two classes that are associated with a many-to-one mapping: <class
I have two classes that I would like to specify as follows: class Club
I have two classes that extend the activity class. Each class has it's own
I have two classes that I would like to merge into a composite. These
I have two classes that don't know anything about themselfs class A, class B.
So let's say I have two classes that inherit a base class that has
I have two classes that can act as a delegate of a third class,
I have two classes that I would like to transform to protobuf messages: [ProtoContract]
I have the following issue. I have two classes that manipulate information but they

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.