0
joe@tronactive.com created
What is the recommended way to use a DBContext directly in a service? Is it something like this? var masterDbContext = (Integr8MasterDbContext) await _customerRepository.GetDbContextAsync();
Or directly inject the DBContext like this? private readonly Integr8MasterDbContext _masterDbContext;
Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
2 Answer(s)
-
0
Hi,
You can't directly inject the DBContext. Because the context instance is controlled by the unit of work system.
So, recommended way is :
var masterDbContext = (Integr8MasterDbContext) await _customerRepository.GetDbContextAsync();Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
This question has been automatically marked as stale because it has not had recent activity.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)