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

I want to use my current application done in Asp.net MVC 3 on mobile
I am creating a script to configure and launch software. My current application requires
I am using a separate class with only static fields, to store current application
We want to integrate webmail with our current application. At present I need to
A website that I'm working on is making extensive use of the HttpContext.Current.Application store
My current application running on 2GB memory Normal GC cycle. I want to increase
In my current application in payment gateway, I want to perform this steps Transfer
In my current application, which is for in-car use, I am displaying a series
I am using a navigation controller in my current application, but I had an
I want to get Assemblies Friendly Names in Current Application Domain and hence I

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.