Hello!

I'm using ASP.NET MVC2 - in my Application_Start method, I setup the
database using StructureMap (an IoC container).

The FIRST request works - but after that, I get 'Table not found'
errors.  It seems the in-memory database gets deleted.

Here is my Application_Start in Global.asax:

public void Application_Start()
        {
            RegisterRoutes(RouteTable.Routes);

            ControllerBuilder.Current.SetControllerFactory(new
StructureMapControllerFactory());

            StructureMapConfig.SetupApplication();

            DataConfig.SetupData();
        }

And here is the StructureMapConfig.SetupApplication static method:

public class StructureMapConfig
    {
        public static void SetupApplication()
        {
            ObjectFactory.Initialize(x =>
            {
                x.AddRegistry(new StructureMapRegistry());

                x.For<Configuration>()
                    .Singleton()
                    .Use(NHibernateConfig.CreateConfiguration());

                x.For<ISessionFactory>()
                    .Singleton()
                    .Use(context =>
context.GetInstance<Configuration>().BuildSessionFactory());

                // Cache each ISession per web request. Remember to
dispose this!
                x.For<ISession>()
                    .HttpContextScoped()
                    .Use(context =>
context.GetInstance<ISessionFactory>().OpenSession());
            });
        }

Any ideas how to make the database stick around after the first
request?

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to