Skip to content

Allow scoped application services to be accessed from the context - #9009

Merged
ajcvickers merged 1 commit into
devfrom
FreshAndMintyListerine0628
Jun 29, 2017
Merged

ajcvickers merged 1 commit into
devfrom
FreshAndMintyListerine0628

Conversation

@ajcvickers

Copy link
Copy Markdown
Contributor

Issue #8797

After going back and forth on this I settled on:

  • Register DbContextOptions as scoped by default
    • This allows scoped services to be used in AddDbContext
    • This allows scoped services to be resolved from context.GetService
    • It will still work fine if scoped services are not needed
  • Add another parameter to AddDbContext to allow the options to be registered as Singleton if needed
    • This can be used for apps that are doing some heavy lifting in AddDbContext

Issue #8797

After going back and forth on this I settled on:
* Register DbContextOptions as scoped by default
  * This allows scoped services to be used in AddDbContext
  * This allows scoped services to be resolved from context.GetService
  * It will still work fine if scoped services are not needed
* Add another parameter to AddDbContext to allow the options to be registered as Singleton if needed
  * This can be used for apps that are doing some heavy lifting in AddDbContext
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants