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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:47:07+00:00 2026-05-12T15:47:07+00:00

In the current application I’m developing I’m using Fluent NHibernate to configure NHibernate for

  • 0

In the current application I’m developing I’m using Fluent NHibernate to configure NHibernate for use as an ORM. I want to be able to add a prefix to all the table names used in the application, so that if I use a database that is already servicing another application, there are no naming conflicts between the two applications.

So for instance if I wanted to add a prefix of Portal_ to each table, the Users table would become Portal_Users.

Of course, I know how to configure each table name in each mapping file, but that’s not really a good solution for what I’m trying to do. If I ever wanted to change the prefix, I would be forced to change each of the mapping files. I want to be able to add (or change) the prefix to all the table names in a single place in my code or configuration.

How does one add a prefix to all table names within an application using NHibernate (or Fluent NHibernate)?

  • 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-12T15:47:08+00:00Added an answer on May 12, 2026 at 3:47 pm

    For a fluent implementation..

     public class AutoPersistenceModelGenerator : IAutoPersistenceModelGenerator
        {
            public AutoPersistenceModel Generate()
            {
                var mappings = new AutoPersistenceModel();
                mappings.AddEntityAssembly(typeof(User).Assembly).Where(GetAutoMappingFilter);
                mappings.Conventions.Setup(GetConventions());
    
    .....
        private Action<IConventionFinder> GetConventions()
        {
            return c =>
            {
                c.Add<PrimaryKeyConvention>();
                c.Add<ReferenceConvention>();
                c.Add<HasManyConvention>();
                c.Add<TableNameConvention>();
    

    ……

           public class TableNameConvention : IClassConvention
            {
                public void Apply(FluentNHibernate.Conventions.Instances.IClassInstance 
    instance)
                {
                    instance.Table(Inflector.Net.Inflector.Pluralize("Portal_" + 
        instance.EntityType.Name));
                    }
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the method Application.Restart() in C# should restart the current application: but it seems
Is it possible to fetch the current application version programmatically for use in urls
I have a pretty standard table set-up in a current application using the .NET
so I'm using LinQ2SQL quite heavily in my current application, and although I have
My current application has a JFrame with about 15 actions stored as fields within
We have a current application where user login credentials are stored in a SQL
In my current application I have a form that requires the user to enter
I came across a problem in my current application that required fiddling with the
I need to know how I can detect the current application pool I am
I have a question regarding handling errors in a J2EE application. Our current application

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.