Pomelo.entityframeworkcore.mysql: Cannot access a disposed object

Created on 30 May 2018  ·  3Comments  ·  Source: PomeloFoundation/Pomelo.EntityFrameworkCore.MySql

1
2
3
4

How should I set to solve this problem?

Cannot access a disposed object. A common cause of this error is disposing a context that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling Dispose() on the context, or wrapping the context in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances.
Object name: 'RepositoryDbContext'.

Most helpful comment

@antonioortizpola is right, the async void is more than likely the issue, it needs to be async Task and should be awaited in the Controller. Controller also needs to be made async.

All 3 comments

Unsure this is a provider issue. See if you can replicate using SQLite EF Core Database Provider.

Mmmm, i do not know if that afects, but you are not using async right, you should be using Tasks, not Threads, and Task.Delay, not Thread.Sleep.
Your async method should return Task, not void, and if you could post the code as text and not as image could make easier for us to make some notes!, But like @mguinness i bet the problem is not in the provider

@antonioortizpola is right, the async void is more than likely the issue, it needs to be async Task and should be awaited in the Controller. Controller also needs to be made async.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

matthewjcooper picture matthewjcooper  ·  4Comments

aramirezh-dev picture aramirezh-dev  ·  3Comments

IonRobu picture IonRobu  ·  3Comments

ptsneves picture ptsneves  ·  3Comments

findmoon picture findmoon  ·  3Comments