Browse Source

Add new UseOpenIddict() extensions for DbContextOptionsBuilder<TContext>

pull/1753/head
Grégoire 3 years ago
committed by GitHub
parent
commit
3f8ae0c165
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 56
      src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreHelpers.cs

56
src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreHelpers.cs

@ -29,7 +29,20 @@ public static class OpenIddictEntityFrameworkCoreHelpers
OpenIddictEntityFrameworkCoreToken, string>();
/// <summary>
/// Registers the OpenIddict entity sets in the Entity Framework Core
/// Registers the OpenIddict entity sets in the Entity Framework Core context
/// using the default OpenIddict models and the default key type (string).
/// </summary>
/// <param name="builder">The builder used to configure the Entity Framework context.</param>
/// <returns>The Entity Framework context builder.</returns>
public static DbContextOptionsBuilder<TContext> UseOpenIddict<TContext>(this DbContextOptionsBuilder<TContext> builder)
where TContext : DbContext
{
((DbContextOptionsBuilder) builder).UseOpenIddict();
return builder;
}
/// <summary>
/// Registers the OpenIddict entity sets in the Entity Framework Core
/// context using the default OpenIddict models and the specified key type.
/// </summary>
/// <remarks>
@ -45,6 +58,24 @@ public static class OpenIddictEntityFrameworkCoreHelpers
OpenIddictEntityFrameworkCoreScope<TKey>,
OpenIddictEntityFrameworkCoreToken<TKey>, TKey>();
/// <summary>
/// Registers the OpenIddict entity sets in the Entity Framework Core
/// context using the default OpenIddict models and the specified key type.
/// </summary>
/// <remarks>
/// Note: when using a custom key type, the new key type MUST be registered by calling
/// <see cref="OpenIddictEntityFrameworkCoreBuilder.ReplaceDefaultEntities{TKey}"/>.
/// </remarks>
/// <param name="builder">The builder used to configure the Entity Framework context.</param>
/// <returns>The Entity Framework context builder.</returns>
public static DbContextOptionsBuilder<TContext> UseOpenIddict<TKey, TContext>(this DbContextOptionsBuilder<TContext> builder)
where TKey : notnull, IEquatable<TKey>
where TContext : DbContext
{
builder.UseOpenIddict<TKey>();
return builder;
}
/// <summary>
/// Registers the OpenIddict entity sets in the Entity Framework Core
/// context using the specified entities and the specified key type.
@ -72,6 +103,29 @@ public static class OpenIddictEntityFrameworkCoreHelpers
TApplication, TAuthorization, TScope, TToken, TKey>>();
}
/// <summary>
/// Registers the OpenIddict entity sets in the Entity Framework Core
/// context using the specified entities and the specified key type.
/// </summary>
/// <remarks>
/// Note: when using custom entities, the new entities MUST be registered by calling
/// <see cref="OpenIddictEntityFrameworkCoreBuilder.ReplaceDefaultEntities{TApplication, TAuthorization, TScope, TToken, TKey}"/>.
/// </remarks>
/// <param name="builder">The builder used to configure the Entity Framework context.</param>
/// <returns>The Entity Framework context builder.</returns>
public static DbContextOptionsBuilder<TContext> UseOpenIddict<TApplication, TAuthorization, TScope, TToken, TKey, TContext>(
this DbContextOptionsBuilder<TContext> builder)
where TApplication : OpenIddictEntityFrameworkCoreApplication<TKey, TAuthorization, TToken>
where TAuthorization : OpenIddictEntityFrameworkCoreAuthorization<TKey, TApplication, TToken>
where TScope : OpenIddictEntityFrameworkCoreScope<TKey>
where TToken : OpenIddictEntityFrameworkCoreToken<TKey, TApplication, TAuthorization>
where TKey : notnull, IEquatable<TKey>
where TContext : DbContext
{
builder.UseOpenIddict<TApplication, TAuthorization, TScope, TToken, TKey>();
return builder;
}
/// <summary>
/// Registers the OpenIddict entity sets in the Entity Framework Core context
/// using the default OpenIddict models and the default key type (string).

Loading…
Cancel
Save