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

Make replacing internal EF services easier in the common case #6306

Closed
ajcvickers opened this issue Aug 12, 2016 · 0 comments
Closed

Make replacing internal EF services easier in the common case #6306

ajcvickers opened this issue Aug 12, 2016 · 0 comments
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Milestone

Comments

@ajcvickers
Copy link
Contributor

Currently when an application needs to replace an internal EF service it must take over creation and management of the internal service provider. This is a significant burden as can be seen in answers for #5845 and #5303. It can also result in bad code being written when the caching requirements for the service provider are not understood--for example #5866.

It would be useful to have an API that can be called in OnConfiguring that would allow a service to be easily replaced without the application needing to take over managing the service provider.

ajcvickers added a commit that referenced this issue Aug 12, 2016
Issue #6306

Adds a ReplaceService method to DbContextOptionsBuilder that is used like this:

```C#
protected internal override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  => optionsBuilder
      .ReplaceService<IModelCustomizer, CustomModelCustomizer>()
      .UseInMemoryDatabase();
```

The replacement service automatically gets the scoping of the original registration.

An exception is thrown if this method is used in combination with UseInternalServiceProvider.
ajcvickers added a commit that referenced this issue Aug 12, 2016
Issue #6306

Adds a ReplaceService method to DbContextOptionsBuilder that is used like this:

```C#
protected internal override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  => optionsBuilder
      .ReplaceService<IModelCustomizer, CustomModelCustomizer>()
      .UseInMemoryDatabase();
```

The replacement service automatically gets the scoping of the original registration.

An exception is thrown if this method is used in combination with UseInternalServiceProvider.
@divega divega added this to the 1.1.0 milestone Aug 12, 2016
ajcvickers added a commit that referenced this issue Aug 17, 2016
Issue #6306

Adds a ReplaceService method to DbContextOptionsBuilder that is used like this:

```C#
protected internal override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  => optionsBuilder
      .ReplaceService<IModelCustomizer, CustomModelCustomizer>()
      .UseInMemoryDatabase();
```

The replacement service automatically gets the scoping of the original registration.

An exception is thrown if this method is used in combination with UseInternalServiceProvider.
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Aug 17, 2016
@ajcvickers ajcvickers modified the milestones: 1.1.0-preview1, 1.1.0 Oct 15, 2022
@ajcvickers ajcvickers removed their assignment Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Projects
None yet
Development

No branches or pull requests

2 participants