I have an MVC4 application using RavenDB as a datastore. The application has MVC/Web, Domain, Data, and Security layers.
I am writing custom membership and role providers that need to initialize the database and access the DocumentStore. I'm writing these class from the Security layer, and would like to use a singleton DocumentStore (set in the application), but I can't figure out how to access it.
Other, examples I see of writing custom providers for RavenDB create new DocumentStore instances within the Provider.Initialize() methods, but that seems to break the rule of having a single DocumentStore per server.
Currently, I create a single instance of the RavenDB DocumentStore in Application_Start(). I have a base controller in the MVC/Web layer that handles the DocumentStore.Session(s).
Is there a way of accomplishing this? Should I move my security logic into the MVC/Web layer to simplify things?