dotnet / dotnet/aspnetcore

Configure Identity in a DbContext with composition

Open
#66,517 2 comments 0 reactions 0 assignees View on GitHub
area-identity feature-request
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

- Trying to have an app's `DbContext` independent from `AspNetCore.Identity`
- Need the ability to inherit other custom `DbContext` that does not use `IdentityDbContext`

### Describe the solution you'd like

The capability to set up Identity entities with composition instead of inheritance, e.g. using extension method on `ModelBuilder`:

```csharp
public class AppDbContext(DbContextOptions options) : DbContext(options)
{
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.ConfigureIdentity(this); // Voilà
}
}
```

### Additional context

_No response_

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.