AddDbContext with ServiceLifetime.Scoped should pass scoped IServiceProvider to optionsAction #8797
Labels
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
type-enhancement
Milestone
When registering DbContext via AddDbContext(Action<IServiceProvider, DbContextOptionsBuilder>) with ServiceLifetime.Scoped i expect IServiceProvider argument passed to the optionsAction to be IServiceProvider from IServiceScope.
Unfortunately AddDbContext adds DbContextOptions as singleton. Should'nt DbContextOptions be also added scoped when using ServiceLifetime.Scoped ?
In my case i resolve many DbContext's which need to use same DbConnection provided by a scoped IDbConnectionProvider. This enables me to call SaveChanges on different contexts in same transaction.
Steps to reproduce
sp argument in AddDbContext should be instance provided by IServiceScope.
Further technical details
EF Core version: 1.1.0
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 10
IDE: Visual Studio 2017
The text was updated successfully, but these errors were encountered: