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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:18:17+00:00 2026-06-13T12:18:17+00:00

My NHibernate mappings include a <database-object> element to define indexes for MS SQL Server

  • 0

My NHibernate mappings include a <database-object> element to define indexes for MS SQL Server 2008. The problem is that this SQL doesn’t get included in the schema when I call SchemaExport.Create. Everything else gets created, but there are no indexes.

One of the entities looks like this, for example:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">

  <class xmlns="urn:nhibernate-mapping-2.2" 
      name="MyApp.Entities.SomeEntity, MyApp.Entities" table="SomeEntity">

    <!- -->

  </class>

  <database-object>
    <create>
      CREATE INDEX [Idx_SomeEntityIndex] ON [SomeEntity] 
          ([Field1] ASC, [Field2] ASC) INCLUDE ( [Field3], [Field4], [Field5])
      CREATE STATISTICS [Stat_SomeEntityStat] ON [SomeEntity] 
          ([Field1], [Field2])
    </create>
    <drop>
      DROP INDEX [Idx_SomeEntityIndex] ON [SomeEntity]
      DROP STATISTICS [Stat_SomeEntityStat]
    </drop>
    <dialect-scope name="NHibernate.Dialect.MsSql2008Dialect, NHibernate"/>
  </database-object>

</hibernate-mapping>

The problem is that this used to work before (probably before moving from NH2 to NH3), and I am not sure if something changed in NHibernate which prevents this from executing.

Dialect matches my dialect in the config file.

  • 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-06-13T12:18:18+00:00Added an answer on June 13, 2026 at 12:18 pm

    Thanks to @OskarBerggren, I got the answer at a different forum. The problem was that the assembly name (NHibernate, in this case) should not have been specified inside the dialect string.

    So, when I changed this:

    <dialect-scope name="NHibernate.Dialect.MsSql2008Dialect, NHibernate"/>
    

    to this:

    <dialect-scope name="NHibernate.Dialect.MsSql2008Dialect"/>
    

    it fixed my issues.

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

Sidebar

Related Questions

I have several NHibernate mappings using a sql-insert element to override the native insert
I'm having a problem with Fluent NHibernate mappings, I think, and can't quite get
Question regarding fluent nHibernate table mappings: Apparently I was under the mistaken impression, that
I've inherited a large set of NHibernate mappings that live in an existing, functional
Is it possible to generate the database schema from the Nhibernate mappings DLL? My
I have a asp.net-mvc website with a SQL server backend (using nhibernate for OR
In order to use my Fluent NHibernate mappings on SQL Azure, I need to
I need to create DTOs from NHibernate POCO objects. The problem is that the
Is it possible to use Fluent NHibernate's PersistenceSpecification to test NHibernate mappings done via
I am trying to get Fluent nHibernate to generate mappings so I can take

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.