dotnet / dotnet/aspnetcore

AddEntityFrameworkStores expects a concrete implementation and AddDbContext<TContextService, TContextImplementation> does not bind the concrete implementation

Open
#4,285 0 comments 0 reactions 0 assignees View on GitHub
affected-few area-identity bug severity-minor
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

I am not sure whether this is actually an issue or just a misunderstanding and I am not sure what the best fix for this would be but when using a service interface and an implementation for `AddDbContext` the actual context is not configured for injection so any attempt to use EntityFramework identity stores (e.g. `UserStore` via `UserManager`) results in an exception because the context cannot be injected.

```
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext();
services.AddIdentity()
.AddEntityFrameworkStores();
}
```

You can work around this by manually binding the context ([as described here](https://stackoverflow.com/questions/52347535)) but it definitely does not feel ideal.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.