title: Creating sessionFactory fluent Nhibernate
body: <p>Im working with <code>MVC4</code> and using <code>Fluent Nhibernate</code> to connect <code>MSSQL</code>. As common solutions I have a <code>createSessionFactory</code> method for creating the session factory which is like this:</p>
  
  <pre><code>public ISessionFactory CreateMSSQLSessionFactory(string server, string DBName, string username, string password)
  {
       soFactory =   Fluently.Configure()
              .Database(MsSqlConfiguration.MsSql2008.ConnectionString(c =&gt; c
                  .Server(server).Database(DBName).Username(username).Password(password)))
              .Mappings(x =&gt; x.FluentMappings.AddFromAssemblyOf&lt;MvcApplication&gt;())           
              .ExposeConfiguration(c =&gt;
                    c.SetProperty("current_session_context_class", "web"))
              .BuildSessionFactory();
  
      return soFactory;
  }
  </code></pre>
  
  <p>I have tried any kind of mapping but it won't work.
  The problem is there when it comes to <code>.BuildSessionFactory();</code> it suddenly skip the return sentence. so the <code>sessionfactory</code> remains null it seems that it cannot complete building session factory!
  The most weird point is that it was perfectly working and suddenly stopped!
  I have already tried every single solution which is provided in this site but nothing changes!</p>