public void UpdateSchema(string sessionFactoryConfigPath) { Check.Require(!string.IsNullOrEmpty(sessionFactoryConfigPath), "sessionFactoryConfigPath may not be null nor empty"); // Attempt to retrieve a stored SessionFactory from the hashtable. if (sessionFactories.ContainsKey(sessionFactoryConfigPath)) sessionFactories.Remove(sessionFactoryConfigPath); //if (null != HttpRuntime.Cache[sessionFactoryConfigPath]) // HttpRuntime.Cache.Remove(sessionFactoryConfigPath); Check.Require(File.Exists(sessionFactoryConfigPath), "The config file at '" + sessionFactoryConfigPath + "' could not be found"); Configuration cfg = new Configuration(); InitializeFilters (cfg); cfg.Configure(sessionFactoryConfigPath); var map = GetMappings(sessionFactoryConfigPath); cfg.AddDeserializedMapping(map, "NHSchemaTest"); cfg.CreateIndexesForForeignKeys(); //new SchemaExport(cfg).Drop(true, true); //new SchemaExport(cfg).Create(true, true); // Now that we have our Configuration object, create a new SessionFactory var update = new SchemaUpdate(cfg); update.Execute(true, true); ISessionFactory sessionFactory = cfg.BuildSessionFactory(); if (sessionFactory == null) { throw new InvalidOperationException("cfg.BuildSessionFactory() returned null."); } sessionFactories.Add(sessionFactoryConfigPath, sessionFactory); //HttpRuntime.Cache.Add(sessionFactoryConfigPath, sessionFactory, null, DateTime.Now.AddDays(7), // TimeSpan.Zero, CacheItemPriority.High, null); }