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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:19:13+00:00 2026-05-11T22:19:13+00:00

I have a reference application that I use to work through DDD issues, and

  • 0

I have a reference application that I use to work through DDD issues, and my current focus is on persistence. An alternate title for this post could have been DDD / TDD persistence tools and methods, but that is a (very) broad topic and I do have a specific question on SQL Server.

I’m going to outline my current tool set in this paragraph as background, so feel free to skip it to just answer the question. I’m using NHibernate, Fluent NHibernate, Rhino, Visual Studio 2008 and SQL Server. My current thinking is to use NHibernate to generate the db after any data mapping change, look at the generated tables in VS 2008, and see if my persistence mapping tests all pass. I had originally wanted to use SQLite as the test db, but I am skeptical that it is an accurate gauge of correct mapping in some ways (like referential integrity). I then tried using SQL Ce, but found it frustrating to eye ball the generated tables with VS. That’s why I’m now figuring to just use SQL Server in the first place.

The following command object generates the db:

public class GenerateNewDb_SqlServer : ICommand
    {
        public GenerateNewDb_SqlServer(Configuration cfg)
            : base(string.Format("Update a Sql Server Database"))
        {
            _cfg = cfg;
        }

        public override void Execute()
        {
            try
            {
                var schema = new SchemaExport(_cfg);
                schema.Create(true, true);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Schema Export Error Message: " + ex);
            }
        }
    }

The problem is that old database objects are still there. I need to somehow delete the whole sql server db each time before using the NHibernate schema tool to create it. Can someone please tell me how to do that in code?


Is there something off the NHibernate.Cfg.Configuration object I can use to drop the db? What would the code look like?

Cheers,
Berryl

  • 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-11T22:19:13+00:00Added an answer on May 11, 2026 at 10:19 pm

    Thankfully, it’s already part of SchemaExport. I’m not sure if it will drop the entire database, but it will drop all the referenced SQL objects. Something like this?

    private void DropSchema(Configuration _cfg)
     {  
            new SchemaExport(_cfg)
                .Drop(
                    false, //script to the console
                    true, //execute against db
                );
     }
    

    P.S. Usually, you’ll see this command run directly before SchemaExport.Create so you get a fresh database…

    P.P.S. bunch of great model-driven stuff for NHibernate here (this screencast series is amazing!)

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

Sidebar

Ask A Question

Stats

  • Questions 167k
  • Answers 167k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use the class attribute Replace <div style="main_spc abc"></div> with <div… May 12, 2026 at 1:29 pm
  • Editorial Team
    Editorial Team added an answer The MembershipProvider is first of all a pluggable, standardised repository.… May 12, 2026 at 1:29 pm
  • Editorial Team
    Editorial Team added an answer I'm Kevin and I work on SharePoint What's likely happening… May 12, 2026 at 1:29 pm

Related Questions

I am using VS 2008 to develop an application that uses a .dll with
I created a separate assembly to contain common extension methods, the extension methods uses
I have a project that is stored in a Subversion repository. In this repository,
I have an ASP.NET MVC application which is using Linq to SQL classes placed

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.