Mingoll.OpenIddict.Management.Storage.EfCore 2.0.0

dotnet add package Mingoll.OpenIddict.Management.Storage.EfCore --version 2.0.0
                    
NuGet\Install-Package Mingoll.OpenIddict.Management.Storage.EfCore -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Mingoll.OpenIddict.Management.Storage.EfCore" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Mingoll.OpenIddict.Management.Storage.EfCore" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Mingoll.OpenIddict.Management.Storage.EfCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Mingoll.OpenIddict.Management.Storage.EfCore --version 2.0.0
                    
#r "nuget: Mingoll.OpenIddict.Management.Storage.EfCore, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Mingoll.OpenIddict.Management.Storage.EfCore@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Mingoll.OpenIddict.Management.Storage.EfCore&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Mingoll.OpenIddict.Management.Storage.EfCore&version=2.0.0
                    
Install as a Cake Tool

OpenIddict.Management.Storage.EfCore

NuGet Downloads Target Frameworks License: MIT

OpenIddict.Management.Storage.EfCore (Mingoll.OpenIddict.Management.Storage.EfCore) delivers complete Entity Framework Core persistence implementations for the OpenIddict Management ecosystem.

Install this package when using EF Core (SQL Server, PostgreSQL, SQLite, MySQL) as your backing database. It provides out-of-the-box management store implementations (EfCoreApplicationManagementStore, EfCoreTokenStore, EfCoreAuthorizationStore, EfCoreScopeManagementStore), enhanced entity types with auditing and metadata properties, batch/bulk operation execution, client secret rotation, and fluent ModelBuilder extensions.


Installation

Install via the .NET CLI:

dotnet add package Mingoll.OpenIddict.Management.Storage.EfCore

Or via the Visual Studio Package Manager Console:

Install-Package Mingoll.OpenIddict.Management.Storage.EfCore

Prerequisites & Dependencies

Supported Frameworks

  • .NET 8.0 (LTS)
  • .NET 9.0 (STS)
  • .NET 10.0

Required Package Dependencies

  • Mingoll.OpenIddict.Management.Core (Abstractions, models, contracts, audit logging)
  • OpenIddict.EntityFrameworkCore (>= 6.x / 7.x)
  • Microsoft.EntityFrameworkCore.Relational (>= 8.x / 9.x / 10.x)

Companion Database Providers

You must reference your preferred EF Core database provider in your host application:

  • Microsoft.EntityFrameworkCore.SqlServer
  • Microsoft.EntityFrameworkCore.Sqlite
  • Npgsql.EntityFrameworkCore.PostgreSQL
  • Pomelo.EntityFrameworkCore.MySql

Configuration & Setup

1. Configure the DbContext

Extend DbContext and register the enhanced management entities. In OnModelCreating, invoke modelBuilder.UseOpenIddictManagement():

using Microsoft.EntityFrameworkCore;
using OpenIddict.Management.Storage.EfCore.Entities;
using OpenIddict.Management.Storage.EfCore.Extensions;

public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : DbContext(options)
{
    public DbSet<ManagementApplication<Guid>> Applications => Set<ManagementApplication<Guid>>();
    public DbSet<ManagementAuthorization<Guid>> Authorizations => Set<ManagementAuthorization<Guid>>();
    public DbSet<ManagementScope<Guid>> Scopes => Set<ManagementScope<Guid>>();
    public DbSet<ManagementToken<Guid>> Tokens => Set<ManagementToken<Guid>>();

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);

        // Configures table mappings, indexes, and relationships for OpenIddict Management entities
        modelBuilder.UseOpenIddictManagement();

        // For custom primary key types (e.g., int, string):
        // modelBuilder.UseOpenIddictManagement<string>();
    }
}

2. Register Services in Program.cs

using Microsoft.EntityFrameworkCore;
using OpenIddict.Management.Storage.EfCore.Extensions;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddDbContext<ApplicationDbContext>(options =>
{
    options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"));
});

// Registers Core services, EF Core stores, event dispatching, and OpenIddict Core entity mappings in one call
builder.Services.AddOpenIddictManagement<ApplicationDbContext>(options =>
{
    options.RoutePrefix = "/api/management";
    options.RequireHttps = true;
    options.EnableAuditLogging = true;
});
Option B: Fluent Builder Registration
using OpenIddict.Management.Extensions;
using OpenIddict.Management.Storage.EfCore.Extensions;

builder.Services.AddOpenIddictManagement(options =>
{
    options.EnableAuditLogging = true;
})
.AddEfCoreStores<ApplicationDbContext>();
Option C: Custom Primary Key Type (TKey)

If your database uses string or int identifiers instead of Guid:

builder.Services.AddOpenIddictManagement<ApplicationDbContext, string>();
Option D: Individual Store Override

If you need to customize an individual store while preserving the rest:

builder.Services.AddApplicationManagementStore<MyCustomAppStore>();
builder.Services.AddTokenStore<MyCustomTokenStore>();

Store Implementations & Features

  • EfCoreApplicationManagementStore (IApplicationManagementService):
    • Full CRUD operations with rich entity mapping (Status, Environment, Tags, AllowedRolesJson, Description, ExtraData).
    • Native client secret rotation with UpdateClientSecretAsync.
    • Batch operations: BulkCreateAsync and BulkDeleteAsync returning BulkOperationResultDto.
    • Environment-wide status transitions via SetStatusByEnvironmentAsync.
    • Automatic event dispatching to IManagementEventPublisher for audit trail tracking.
  • EfCoreScopeManagementStore (IScopeManagementService):
    • Scope CRUD, resource mappings, descriptions, and paginated searches.
    • Batch creation (BulkCreateAsync) and batch deletion (BulkDeleteAsync).
  • EfCoreTokenStore (IOpenIddictTokenManager):
    • Filtered token queries, token count aggregations, and daily issuance timelines.
    • Revocation by user ID, client ID, session ID, or individual token ID.
  • EfCoreAuthorizationStore (IOpenIddictAuthorizationManager):
    • Authorization tracking, session queries, and bulk session revocation.

Usage Example

Injecting and Using Management Services

using OpenIddict.Abstractions;
using OpenIddict.Management.Contracts;
using OpenIddict.Management.Dto;
using OpenIddict.Management.Enums;
using OpenIddict.Management.Results;

public class IdentityAdministrationService(
    IApplicationManagementService applicationService,
    IOpenIddictTokenManager tokenManager,
    IScopeManagementService scopeService)
{
    public async Task CreateClientAppAsync(CancellationToken cancellationToken)
    {
        // 1. Create a client application
        var createResult = await applicationService.CreateAsync(new ApplicationCreateDto
        {
            ClientId = "mobile-portal-app",
            DisplayName = "Mobile Portal Application",
            ClientSecret = "SuperSecretKey987654!",
            Environment = ApplicationEnvironment.Production,
            ContactEmail = "security@enterprise.local",
            Organization = "Enterprise Mobile Team",
            Tags = ["Mobile", "iOS", "Android"],
            Permissions = [
                OpenIddictConstants.Permissions.Endpoints.Token,
                OpenIddictConstants.Permissions.Endpoints.Authorization,
                OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode,
                OpenIddictConstants.Permissions.GrantTypes.RefreshToken,
                OpenIddictConstants.Permissions.ResponseTypes.Code,
                OpenIddictConstants.Permissions.Prefixes.Scope + "api_read"
            ],
            RedirectUris = ["https://mobile.enterprise.local/callback"]
        }, cancellationToken);

        if (!createResult.IsSuccess)
        {
            throw new InvalidOperationException($"Creation failed: {createResult.Error.Description}");
        }

        // 2. Rotate client secret
        await applicationService.UpdateClientSecretAsync(
            createResult.Value!.Id, 
            "NewRotatedSecretKey987654!", 
            cancellationToken);

        // 3. Batch delete applications
        await applicationService.BulkDeleteAsync(["old-app-id-1", "old-app-id-2"], cancellationToken);
    }

    public async Task RevokeUserSessionsAsync(string userId, CancellationToken cancellationToken)
    {
        // Revoke all active tokens for a specific user across all clients
        Result<RevocationResultDto> revocationResult = await tokenManager.RevokeByUserAsync(userId, cancellationToken);
        if (revocationResult.IsSuccess)
        {
            Console.WriteLine($"Revoked {revocationResult.Value.RevokedTokensCount} tokens for user {userId}.");
        }
    }

    public async Task<PagedResult<TokenListDto>> QueryActiveTokensAsync(CancellationToken cancellationToken)
    {
        // Query tokens with typed filters
        var filter = new TokenFilterRequest
        {
            Page = 1,
            PageSize = 25,
            Status = TokenStatus.Valid,
            Type = OpenIddictConstants.TokenTypeHints.AccessToken
        };

        var result = await tokenManager.ListTokensAsync(filter, cancellationToken);
        return result.Value;
    }
}

Package Purpose
Mingoll.OpenIddict.Management.Core Shared contracts, DTOs, domain models, audit trail models, and options.
Mingoll.OpenIddict.Management.Endpoints Ready-to-map ASP.NET Core Minimal API endpoint groups.
Mingoll.OpenIddict.Management.Dashboard Razor Class Library admin dashboard UI for visual database administration.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 72 10/4/2026
1.2.0 85 9/24/2026
1.1.0 90 9/16/2026
1.0.0 93 9/13/2026