We are attempting to use Hangfire for processing background jobs in an existing web application (code first EF).
This is messaged based and we have a number of Logics registered in a unity IOC container (we resolve based on the name of the message sent).
This appears to be working ok using a unity based Job Activator; however we are getting a performance issue when trying to create a new instance of our DBContext (we have a factory class DBContextFactory that does this and is an injected interface from Unity).
Once the background job starts and we it reaches the point where it calls for a new context from the above factory it takes ages (minutes) to create this where as in a usual synchronous context it is near instant.
My question is: are we missing anything? I’m not sure whether Lifetime managers come into play here?
Happy to clarify anything, thanks!