2

I am using fluent nhibernate to create 3 databases at run time using 3 sessions.

 ISessionFactory sessionFactory = Fluently.Configure()
            .Database(MsSqlConfiguration
            .MsSql2008
            .ConnectionString(c => c
                .Server(databaseServer)
                .Database(dataBaseName)
                .Username("sa").Password("sa123_MTTS")))
                .Mappings(m => m.FluentMappings.AddFromAssemblyOf<NHibernateSessionFactory>())
                .ExposeConfiguration(c => c.SetProperty("command_timeout", (System.TimeSpan.FromMinutes(10).TotalSeconds).ToString()))
                .ExposeConfiguration(BuildSchema)
                .BuildSessionFactory();

private static void BuildSchema(Configuration config)
{
    new SchemaUpdate(config).Execute(false, true);
}

Ex:

Here I am creating the database with names like "123", "234","345".

then I delete the database 123.

after deleting I closed the session also

sessionfactory.Close(); 

now again i add a database with the same name as the deleted database, "123".

SchemaUpdate(config).Execute() 

is called. Nhibernate creates the database, but the tables are not created in the database, and I did not get any exceptions.

I don't know what's wrong with this.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Vikram Bose
  • 3,197
  • 2
  • 16
  • 33

1 Answers1

0

If you have access to SQL Profiler have it running while you are executing your code and see if you are getting some messages from SQL regarding the code that NHibernate is trying to execute.

I have seen situations were NHibernate gets an error from SQL and does not report it back to the client. That was mostly foreign key violations or columns that are set not nullable in SQL but are mapped as nullable with NHibernate. The result of the errors was an unreported rollback of the SQL code.

The error in SQL Profiler should give you a better idea of what is going on.