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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:30:39+00:00 2026-05-24T07:30:39+00:00

Currently our new database design is changing rapidly and I don’t always have time

  • 0

Currently our new database design is changing rapidly and I don’t always have time to keep up to date with the latest changes being made. Therefore I would like to create some basic integration tests that are basically sanity checks on my mappings against the database.

Here are a few of the things I’d like to accomplish in these tests:

  1. Detect columns I have not defined in my mapping but exist in the database
  2. Detect columns I have mapped but do NOT exist in the database
  3. Detect columns that I have mapped where the data types between the database and my business objects no longer jive with each other
  4. Detect column name changes between database and my mapping

I found the following article by Ayende but I just want to see what other people out there are doing to handle these sort of things. Basically I’m looking for simplified tests that cover a lot of my mappings but do not require me to write seperate queries for every business object in my mappings.

  • 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-24T07:30:40+00:00Added an answer on May 24, 2026 at 7:30 am

    I’m happy with this test, that comes from the Ayende proposed one:

    [Test]
            public void PerformSanityCheck()
            {
                foreach (var s in NHHelper.Instance.GetConfig().ClassMappings)
                {
                    Console.WriteLine(" *************** " + s.MappedClass.Name);
    
                        NHHelper.Instance.CurrentSession.CreateQuery(string.Format("from {0} e", s.MappedClass.Name))
                            .SetFirstResult(0).SetMaxResults(50).List();
    
                }
            }
    

    I’m using plain old query since this version comes from a very old project and I’m to lazy to update with QueryOver or Linq2NH or something else…
    It basically ping all mapped entities configured and grasp some data too in order to see that all is ok. It does not care if some field exists in the table but not on the mapping, that can generate problem in persistence if not nullable.
    I’m aware that Fabio Maulo has something eventually more accurate.
    As a personal consideration, if you are thinking on improvement, I would try to implement such a strategy: since mapping are browsable by API, look for any explicit / implicit table declaration in the map, and ping it with the database using the standard schema helperclasses you have inside NH ( they eventually uses the ADO.NET schema classes, but they insulate all the configuration stuff we already did in NH itself) By playng a little with naming strategy we can achieve a one by one table field check list. Another improvement can be done by, in case of unmatching field, looking for a candidate by applying Levensthein Distance to all the available names and choosing one if some threshold requisites are satisfied. This of course is useless in class first scenarios when the DB schema are generated by NH itself.

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

Sidebar

Related Questions

We don't currently have our SQL Server objects in any form of source control.
We are currently working on a new version of our main application. one thing
Currently in our enterprise we have a situation that i think it's not very
currently i try to create a push server instance for new activities around our
The question says it all. Our application is currently authenticating users against a database.
We're about to embark on development of a new product. Our current product is
We're about to start a new project, and our client's current application is .NET
Currently our Java application uses the values held within a tab delimited *.cfg file.
Currently our developent enviroment consists of a Dev server, a Staging server and a
I'm setting up some monitoring on a few SQL Servers. Currently our environment uses

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.