1

I'm trying to show the SQL in the console of Visual Studio but it doesn't work. I'm using fluent nhibernate with the following code:

string connectionString = WebCondStaClara.Lib.ConfigDB.StringConexao;

ISessionFactory sessionFactory = Fluently.Configure()
            .Database(
                MySQLConfiguration.Standard.ConnectionString(connectionString).ShowSql
            )
            .Mappings(m =>
                m.FluentMappings
                    .AddFromAssemblyOf<Person>()
                    .AddFromAssemblyOf<Home>()
            )
            .ExposeConfiguration(cfg => new SchemaExport(cfg)
            .Create(true, false)).BuildSessionFactory();

return sessionFactory.OpenSession();

What am I doing wrong?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Sammy Davis
  • 117
  • 4
  • 13

1 Answers1

1

(Fluent)NHibernate uses log4net to provide logging support. You have to configure log4net appropriately (build up a configuration with a console, debug or trace appender and let the loggers use these appenders).

Have a look here: How to log SQL calls with NHibernate to the console of Visual Studio?

Udontknow
  • 1,472
  • 12
  • 32