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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:48:10+00:00 2026-05-27T18:48:10+00:00

if my ClassMap contains a Reference(m => m.Store).Column(StoreId) and I call SchemaExport, then my

  • 0

if my ClassMap contains a Reference(m => m.Store).Column(“StoreId”) and I call SchemaExport, then my database table contains two foreign key columns, one named ‘StoreId’ and one named ‘Store_id’.

If I leave the Column() method, then its only gonna create the ‘Store_id’ column.

Is this a bug in the FluentNHibernate framework?
I’d like to have the ‘StoreId’ column only.

Thanks in advance.

public class EntityMap<T> : ClassMap<T> where T : Entity
{
    public EntityMap()
    {
        Id( m => m.Id );
    }
}

public class StoreMap : EntityMap<Store>
{
    public StoreMap()
    {
        Map( m => m.Name );
        HasMany( m => m.Staff )
            .Inverse()
            .Cascade.All();
        HasManyToMany( m => m.Catalogue )
            .Table( "Store_Product" )
            .Cascade.All();
    }
}

public class EmployeeMap : EntityMap<Employee>
{
    public EmployeeMap()
    {
        Map( m => m.LastName );
        Map( m => m.FirstName );
        References( m => m.Store ).Column( "StoreId" );
    }
}

public class ProductMap : EntityMap<Product>
{
    public ProductMap()
    {
        Map( m => m.Name );
        HasManyToMany( m => m.Stores )
            .Table( "Store_Product" )
            .Inverse()
            .Cascade.All();
    }
}
  • 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-27T18:48:11+00:00Added an answer on May 27, 2026 at 6:48 pm

    Found the solution now, though its not described anywhere I looked.

    You have to set the column bidirectional. Then the “Store_id” column disappears. Thank you all for your answers!

    For my above example:

    public class EntityMap<T> : ClassMap<T> where T : Entity
    {
        public EntityMap()
        {
            Id( m => m.Id );
        }
    }
    
    public class StoreMap : EntityMap<Store>
    {
        public StoreMap()
        {
            Map( m => m.Name );
            HasMany( m => m.Staff )
                .KeyColumn( "StoreId" )
                .Inverse()
                .Cascade.All();
            HasManyToMany( m => m.Catalogue )
                .Table( "Store_Product" )
                .ParentKeyColumn( "StoreId" )
                .ChildKeyColumn( "ProductId" )
                .Cascade.All();
        }
    }
    
    public class EmployeeMap : EntityMap<Employee>
    {
        public EmployeeMap()
        {
            Map( m => m.LastName );
            Map( m => m.FirstName );
            References( m => m.Store ).Column( "StoreId" );
        }
    }
    
    public class ProductMap : EntityMap<Product>
    {
        public ProductMap()
        {
            Map( m => m.Name );
            HasManyToMany( m => m.Stores )
                .Table( "Store_Product" )
                .ParentKeyColumn( "ProductId" )
                .ChildKeyColumn( "StoreId" )
                .Inverse()
                .Cascade.All();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table Parent and a table Child. Child contains a foreign-key to
I am having some redundant primary key issues. I have an Item which contains
I have the following entities: User Role and then a join table: UsersRoles (UserId,
I tried to change the table and column names of my Employee entity by
I have a table http://img36.imageshack.us/i/beztytuuszxq.png/ and mapping: public class CategoryMap : ClassMap<Category> { public
I need to use ClassMaps instead of auto mapping because of legacy database. But
I am using Nhibernate with Fluent, to persist a SQL Server 2008 express database
In FluentNHibernate when should I use ClassMap and when IAutoMappingOverride<Entity> for my EntityMap classes.
Given that I am implementing a read-only UI, how do I create a ClassMap
Given the following Fluent NHibernate maps: public class FastTrackPackageClassMap : ClassMap<FastTrackPackage> { public FastTrackPackageClassMap()

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.