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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:43:50+00:00 2026-05-15T16:43:50+00:00

If I have a parent class: public class Parent { public Parent() { Children

  • 0

If I have a parent class:

public class Parent
{
    public Parent()
    {
        Children = new List<Child>();
    }

    IList<Child> Children {get; private set;}
}

and a child class like so:

public class Child
{
     public SomeThirdClass Friend {get; set;}
}

Whenever I let the Fluent NHibernate’s automapper hit these guys, it makes the Child class have a non-nullable foreign key. I have altered a few automapping conventions and some overrides for certain classes, but for this particular pair only the Parent class has an override. The override does not specify how to map the collection part for the Parent class.

Is making a foreign key not-nullable in the child of a collection the default behavior, or have I F’ed something up?

How would one specify in a mapping override class that the child foreign key is nullable?

PEACE!

  • 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-15T16:43:51+00:00Added an answer on May 15, 2026 at 4:43 pm

    I was able to solve the problem by removing a fluent mapping of a 4th GrandParent class, and allowing the automapper to map that class. Before I had not allowed the automapper to map the GrandParent class because I had a fluent mapping of that class. Somehow this conflict between fluent and auto mappings caused the foreign key in Child to be not-nullable.

    I can’t say that I completely understand what went wrong, so caution is advised when following my solution. But I can say that combining Fluent Mappings and Automappings definitely increases the complexity of debugging persistence issues.

    Alternate Solution: I came across this problem again another two times, and I noticed that if I call KeyColumn(string columnName) in the IAutoMappingOverride for the Parent, the foreign key in the child class will default to Nullable, rather than Not-Null. Crazy Huh?

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

Sidebar

Related Questions

I have a KMainWindow: //file.h class MainWindow: public KMainWindow { public: MainWindow(QWidget *parent =
Let's have the following class hierarchy: public class ParentClass implements SomeInterface { } public
I have an inherited QTreeWidget (called PackList) class and its parent is a KXmlGuiWindow.
When you have parent-child tables and you wish to use a DetailsView to edit
I have db table with parent child relationship as: NodeId NodeName ParentId ------------------------------ 1
I have a need to close a parent form from within child form from
I have an IList that contains items ( parent first ), they need to
I have a parent object which has a one to many relationship with an
There has to be a simple explanation for this. I have a parent <div>
I have a module in the parent directory of my script and I would

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.