I create entity framework db context in startup
services.AddTransient<MyContext>(_ => new MyContext(connectionString));
I inject this context in every service class where I need entity framework to add/edit/delete or what ever.
private readonly MyContext context;
public ArchiveService(MyContext context)
{
this.context = context;
}
For IoC i am using Microsoft.Extensions.DependencyInjection. This mean that my dependency injection container is responsible to dispose db context.
How can I be sure that context is disposed?
Do I need to configure something to dispose db context?
Thank you for help.