private void ConfigureNHibernate(IKernel container) { #if EXPLODEDB //recreate Schema var sessionFactory = Fluently.Configure() .Database( MsSqlConfiguration.MsSql2008.ConnectionString( c => c.FromConnectionStringWithKey("owDbConn"))) .CurrentSessionContext("web") .ExposeConfiguration(cfg => new SchemaUpdate(cfg).Execute(false, true)) .Mappings(m => m.FluentMappings.AddFromAssemblyOf <sysBaseRuleset>()) .BuildSessionFactory(); //seed data #if SEED_DATA var session = sessionFactory.OpenSession(); nwdbRepository nwRepo = new nwdbRepository(session); nwRepo.SeedMockData(); #endif #else var sessionFactory = Fluently.Configure() .Database( MsSqlConfiguration.MsSql2008.ConnectionString( c => c.FromConnectionStringWithKey("owDbConn"))) .CurrentSessionContext("web") .ExposeConfiguration(cfg => new SchemaUpdate(cfg).Execute(false, true)) .Mappings(m => m.FluentMappings.AddFromAssemblyOf <sysBaseRuleset>()) .BuildSessionFactory(); #endif //Bind Created or Updated to Ninject container.Bind <ISessionFactory>().ToConstant(sessionFactory); }
public void nwDB_SeedRepo() { nwdbConnection nw2 = new nwdbConnection(true); sessionFactory = nw.Factory; repo = new nwdbRepository(sessionFactory.OpenSession()); repo.SeedMockData(); }