public void PrepareSessionFactory()
        {
            Configuration = new Configuration();
            Configuration.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>())
                .DataBaseIntegration(db =>
                                         {
                                             db.ConnectionStringName = "db";
                                             db.Dialect<MsSql2008Dialect>();
                                         });
            Configuration.SetProperty("show_sql", "true");
            Configuration.SetDefaultAssembly("NHibernateDeepDive");
            Configuration.SetDefaultNamespace("NHibernate_Deep_Dive.Entities");
            Configuration.AddXmlFile("ClearDatabaseScript.hbm.xml");
            foreach (var mappingFile in Directory.GetFiles(MappingsDirectory))
            {
                Configuration.AddXmlFile(mappingFile);
            }
            AdjustConfiguration(Configuration);
            Configuration.SessionFactory().GenerateStatistics();

            SessionFactory = Configuration.BuildSessionFactory();

            //new SchemaExport(Configuration).Drop(false, true);
            new SchemaExport(Configuration).Execute(false, true, false);

            BeforeTestRun();
            PopulateDatabase();

            HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize();
        }
		static ExampleApplication()
		{
			log4net.Config.XmlConfigurator.Configure();
			Configuration = new Configuration();
			string nhConfigPath = HostingEnvironment.MapPath("~/App_Data/hibernate.cfg.xml");
			if (File.Exists(nhConfigPath))
			{
				Configuration.Configure(nhConfigPath);
			}
			Configuration.SetDefaultAssembly(typeof(Item).Assembly.FullName)
				.SetDefaultNamespace(typeof(Item).Namespace)
				.AddDirectory(new DirectoryInfo(HostingEnvironment.MapPath("~/App_Data/")));
			
			SessionFactory = Configuration.BuildSessionFactory();
		}
		public void SetDefaultAssemblyAndNamespace()
		{
			string hbmFromDomainModel =
				@"<?xml version='1.0' ?>
<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2'>
	<class name='A'>
		<id name='Id' column='somecolumn'>
			<generator class='native' />
		</id>
	</class>
</hibernate-mapping>";

			string hbmFromTest =
				@"<?xml version='1.0' ?>
<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2'>
	<class name='LocatedInTestAssembly' lazy='false'>
		<id name='Id' column='somecolumn'>
			<generator class='native' />
		</id>
	</class>
</hibernate-mapping>";

			Configuration cfg = new Configuration();
			cfg
				.SetDefaultAssembly("NHibernate.DomainModel")
				.SetDefaultNamespace("NHibernate.DomainModel")
				.AddXmlString(hbmFromDomainModel);

			cfg
				.SetDefaultAssembly("NHibernate.Test")
				.SetDefaultNamespace(typeof(LocatedInTestAssembly).Namespace)
				.AddXmlString(hbmFromTest);

			cfg.BuildSessionFactory().Close();
		}