title: currentsessioncontext fluent nhibernate how to do it?
body: <p>I am trying to use fluent with session per request. I am following a "recipe" from nhibernate cookbook however it uses the nhibernate config file.</p>
  
  <p>I am not sure what is better but right now I am sticking with fluent config just because I would not know how to set the nhibernate config file to use fluent mapping and vanilla nhibernate mapping(hbm files).</p>
  
  <pre><code>namespace Demo.WebUI
  {
      public class MvcApplication : NinjectHttpApplication
      {
          public static ISessionFactory SessionFactory { get; private set; }
  
          protected override void OnApplicationStarted()
          {
              SessionFactory = Fluently.Configure()
                  .Database(MsSqlConfiguration.MsSql2008.ConnectionString(
                      c =&gt; c.FromConnectionStringWithKey("test")))
                  .Mappings(m =&gt; m.FluentMappings
                      .AddFromAssemblyOf
                       &lt;Demo.Framework.Data.NhibernateMapping.UserMap&gt;())
                  .ExposeConfiguration(BuidSchema)
                  .BuildSessionFactory();
          }
  
          protected void Application_BeginRequest(object sender, EventArgs e)
          {
              var session = SessionFactory.OpenSession();
              //CurrentSessionContext.Bind(session);
          }
  
          protected void Application_EndRequest(object sender, EventArgs e)
          {
              //var session = CurrentSessionContext.Unbind(SessionFactory);
              SessionFactory.Dispose();
          }
      }
  }
  </code></pre>
  
  <p>As you can see in the Begin_Request the books tutorial had</p>
  
  <pre><code>CurrentSessionContext.Bind(session);
  </code></pre>
  
  <p>However if I use this it throws a error since I don't have the nhibernate config file in use.</p>
  
  <p>So how do I change it to use fluent configuration? Or do I not even need to do this step?(ie is it done internally?)</p>