Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid using ActivatorServices for common DbContext constructor #21254

Merged
merged 1 commit into from
Jun 13, 2020

Conversation

ajcvickers
Copy link
Member

Improvement to #18575

This change checks if the DbContext has the usual constructor taking just options:

MyContext(DbContextOptions<MyContext> options)

If it does, then we create a delegate (once in a singleton service) and use that to create context instances. This avoids using ActivatorServices and falling out of constructor injection (other than the delegate) for the common case.

@ajcvickers ajcvickers requested a review from a team June 13, 2020 16:07
@ajcvickers
Copy link
Member Author

/cc @JeremyLikness

Improvement to #18575

This change checks if the DbContext has the usual constructor taking just options:

```C#
MyContext(DbContextOptions<MyContext> options)
```

If it does, then we create a delegate (once in a singleton service) and use that to create context instances. This avoids using ActivatorServices and falling out of constructor injection (other than the delegate) for the common case.
@ajcvickers ajcvickers merged commit 63d84c9 into master Jun 13, 2020
@ajcvickers ajcvickers deleted the SpeedBoatToDevon0613 branch June 13, 2020 19:22
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.

2 participants