Hello everybody,
I am using ASP.NET Core 1.0 and I need to schedule tasks (Hangfire style). I am using FluentScheduler v5.1.3 with structuremap as a DI container.
The thing is, when I run jobs that use the EF Core, I get a context disposed exception.
I initliaze StructureMap simply populating it using an IServiceCollection (from asp.net core) where all services are registered as transient.
I start my job like this :
JobManager.AddJob(() => _sync.SyncFromDomain(vm.Domain), s => s.ToRunOnceIn(5).Seconds());
I don't initialize the job manager with a registry.
The job gets fired after 5 seconds but, as soon as I hit the repository code where the context is needed, this exception gets thrown :
Exception thrown: 'System.ObjectDisposedException' in Microsoft.EntityFrameworkCore.dll