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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:38:44+00:00 2026-05-16T07:38:44+00:00

I was trying to change a convention so that my IDs follow this simple

  • 0

I was trying to change a convention so that my IDs follow this simple rule: ProductCode, CustomerCode, OrderCode etc etc.
I’ve found a simple way to do that adding a convention:

public class PrimaryKeyNameConvention : IIdConvention
        {
            public void Apply(FluentNHibernate.Conventions.Instances.IIdentityInstance instance)
            {
                instance.Column(instance.EntityType.Name + "Code");
            }
        } 

Now I’ve got what I wanted but it seems that FluentNhibernate refuses to apply the same rule with column referencing my primary keys.
EX: my table Customer will have a PK called CustomerCode but my table Order will have a reference column called Customer_Id.
I’ve tried different ways to rename the column Customer_Id in CustomerCode (table Order) but it seems that nothing works properly.
The only solution which seems to work is adding a convention like this:

public class ReferenceConvention : IReferenceConvention
        {
            public void Apply(FluentNHibernate.Conventions.Instances.IManyToOneInstance instance)
            {
                instance.Column(instance.Property.PropertyType.Name + "Code");
            }
        }

but now FluentNhibernate creates two columns which reference my primary key: CostumerCode and Customer_Id.

I can’t figure out what I am doing wrong.
Any help would be apreciated.

Regards,

Alberto

  • 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-16T07:38:44+00:00Added an answer on May 16, 2026 at 7:38 am

    Take a look at the ForeignKeyConvention base-class.

    The ForeignKeyConvention is an amalgamation of several other conventions to provide an easy way to specify the naming scheme for all foreign-keys in your domain. This is particularly useful because not all the foreign-keys are accessible in the same way, depending on where they are; this convention negates need to know about the underlying structure.

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

Sidebar

Related Questions

Need your help, trying to change this script: https://github.com/MrHus/jquery-monthly-ical To load external JSON data
I currently have a couple of forms that I'm trying to change the button
Is this possible!!?!?!?!? I'm trying to make a set of classes that model a
I'm using JpGraph to make a Gantt chart for a convention. I found this
I am trying to change a specific value, which has no connection to it's
I'm trying change an input mask for textbox when the the check box has
Am trying to change the button frame according to the orientation change but button
I´m trying to change a spring jsp example to use freemarker. I changed all
im trying to change font globally for whole application, the problem is, i am
I am trying to change the color of my draggable if it is reverting

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.