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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:23:18+00:00 2026-05-23T01:23:18+00:00

I’m using fluentnhibernate on SQL Server 2008. I have to objects Staff public class

  • 0

I’m using fluentnhibernate on SQL Server 2008.

I have to objects Staff

public class Staff : BaseEntity
{
    public virtual string UserName { get; set; }
    public virtual string FirstName { get; set; }
    public virtual string LastName { get; set; }
    public virtual string Email { get; set; }
    public virtual bool Active { get; set; }
    public virtual StaffRole StaffRole { get; set; }
}

and StaffRole

public class StaffRole : BaseEntity
{
    public virtual int RoleId { get; set; }
    public virtual int RoleName { get; set; }
    public virtual IList<Staff> Staffs { get; set; }
}

and mapped them accordingly:

public class StaffRoleMap : ClassMap<StaffRole>
{
    public StaffRoleMap()
    {
        Id(x => x.RoleId).Not.Nullable().Length(15);
        Map(x => x.RoleName).Not.Nullable().Length(75);
        HasMany(x => x.Staffs);
    }
}
public class StaffMap : ClassMap<Staff>
{
    public StaffMap()
    {
        Id(x => x.UserName).Not.Nullable().Length(15);
        Map(x => x.FirstName).Not.Nullable().Length(25);
        Map(x => x.LastName).Not.Nullable().Length(25);
        Map(x => x.Email).Not.Nullable().Length(30);
        Map(x => x.Active).Not.Nullable().Default("1");
        References(x => x.StaffRole)
            .ForeignKey("FKStaffRole")
            .Column("RoleId")
            .Cascade.None()
            .Not.Nullable()
            ;
    }
}

When i call schemaexport, why is it generating 2 foreign keys for the StaffRole? I always get RoleId and StaffRole_id. RoleId is correct since it is not nullable, but the extra column/fk is nullable.

Am I missing something here?

  • 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-23T01:23:19+00:00Added an answer on May 23, 2026 at 1:23 am

    Yes. You must set “inverse” on one side of the relationship. This would be equivalent to setting inverse = true in regular nhibernate xml config.

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

Sidebar

Related Questions

public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
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
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

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.