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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:49:13+00:00 2026-05-26T03:49:13+00:00

Application has many extension assemblies and they contain mappings for their classes. I need

  • 0

Application has many extension assemblies and they contain mappings for their classes. I need to add prefix to all (base, join, many-to-many, …) table names in those mappings.

E.g.

Assembly:        ~/bin/Extensions/Foo.dll
Original table:  Page
New table:       Ext_Foo_Page

Assembly:        ~/bin/Extensions/Bar.dll
Original table:  Page
New table:       Ext_Bar_Page

What’s the most straightforward way to do that?

I tried this

public class TableNameConvention : IClassConvention, IJoinedSubclassConvention, IHasManyToManyConvention
{
    private string getPrefix()
    {
        return "Ext_Test_";
    }
    public void Apply(FluentNHibernate.Conventions.Instances.IClassInstance instance)
    {
        instance.Table(getPrefix() + instance.TableName);
    }

    public void Apply(FluentNHibernate.Conventions.Instances.IJoinedSubclassInstance instance)
    {
        instance.Table(getPrefix() + instance.TableName);
    }
    public void Apply(FluentNHibernate.Conventions.Instances.IManyToManyCollectionInstance instance)
    {
        instance.Table(getPrefix() + instance.TableName);
    }
}

but it doesn’t change table names even though those methods are executed.

EDIT – The configuration

var sb = new StringBuilder();
var sw = new StringWriter(sb);

var cfg = Fluently.Configure()
    .Database(MsSqlConfiguration.MsSql2008.ConnectionString(b => b.Server(@".\SQLEXPRESS").Database("test123").Username("sa").Password("...")))
    .Mappings(m => m.FluentMappings.AddFromAssembly(assembly).Conventions.Add<TableNameConvention>().ExportTo(sw))
    .ExposeConfiguration(c => { new SchemaUpdate(c).Execute(false, true); })
    .BuildSessionFactory();

var xml = sb.ToString();
  • 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-26T03:49:13+00:00Added an answer on May 26, 2026 at 3:49 am

    with FNH 1.2.0.712

    it works with

    var model = new PersistenceModel();
    model.Add(typeof(EntityMap));
    model.Conventions.Add<TableNameConvention>();
    model.WriteMappingsTo(Console.Out);
    

    but not with

    m.FluentMappings.Add(typeof(EntityMap)).Conventions.Add<TableNameConvention>().ExportTo(Console.Out)
    

    it’s not called in the second example, maybe bug. but the following works

    .Mappings(m => 
    {
        m.AutoMappings.Add(() => new AutoPersistenceModel().Conventions.Add<TableNameConvention>());
        m.FluentMappings.Add(typeof(EntityMap)).ExportTo(Console.Out);
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My application has many many mdi forms and they are created after successfull user
I have an application which has many services and one UI module. All these
I have an iPad application which has many categorized images I need to switch
I have a problem with my application: my application has many forms and need
My application has many models, many of which contain percentage data. These are represented
Our application has many controls that are created dynamically. For example, a navigation pane
I have an application that has many different types of objects that each persist
I have a multithreaded application that has many concurrent operations going on at once.
I'm currently working on a large and old C++ application that has had many
I'm building WPF client application. I'm following MVC pattern. The project solution has many

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.