/* * Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) * See https://github.com/openiddict/openiddict-core for more information concerning * the license and the contributors participating to this project. */ using JetBrains.Annotations; using OpenIddict.EntityFramework; using OpenIddict.EntityFramework.Models; namespace System.Data.Entity { /// /// Exposes extensions allowing to register the OpenIddict Entity Framework 6.x entity sets. /// public static class OpenIddictEntityFrameworkHelpers { /// /// Registers the OpenIddict entity sets in the Entity Framework 6.x context /// using the default OpenIddict models and the default key type (string). /// /// The builder used to configure the Entity Framework context. /// The Entity Framework context builder. public static DbModelBuilder UseOpenIddict([NotNull] this DbModelBuilder builder) => builder.UseOpenIddict(); /// /// Registers the OpenIddict entity sets in the Entity Framework 6.x /// context using the specified entities and the specified key type. /// Note: using this method requires creating non-generic derived classes /// for all the OpenIddict entities (application, authorization, scope, token). /// /// The builder used to configure the Entity Framework context. /// The Entity Framework context builder. public static DbModelBuilder UseOpenIddict([NotNull] this DbModelBuilder builder) where TApplication : OpenIddictApplication where TAuthorization : OpenIddictAuthorization where TScope : OpenIddictScope where TToken : OpenIddictToken where TKey : IEquatable { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } builder.Configurations .Add(new OpenIddictApplicationConfiguration()) .Add(new OpenIddictAuthorizationConfiguration()) .Add(new OpenIddictScopeConfiguration()) .Add(new OpenIddictTokenConfiguration()); return builder; } } }