From a384f6e5a8233b7ca6dc434528876d6c36de70fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Sun, 5 Jun 2016 16:59:24 +0200 Subject: [PATCH] Reorder OpenIddictContext's generic arguments to allow specifying a custom TRole entity easily --- .../OpenIddictContext.cs | 49 ++++++++++++++----- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/src/OpenIddict.EntityFramework/OpenIddictContext.cs b/src/OpenIddict.EntityFramework/OpenIddictContext.cs index a6957abb..40303b81 100644 --- a/src/OpenIddict.EntityFramework/OpenIddictContext.cs +++ b/src/OpenIddict.EntityFramework/OpenIddictContext.cs @@ -29,11 +29,10 @@ namespace OpenIddict { /// Represents an OpenIddict-powered Entity Framework context. /// /// The type of the User entity. - public class OpenIddictContext : OpenIddictContext + public class OpenIddictContext : OpenIddictContext where TUser : OpenIddictUser { /// /// Initializes a new OpenIddict context without configuring the Entity Framework options. @@ -52,11 +51,10 @@ namespace OpenIddict { /// /// The type of the User entity. /// The type of the primary key used by the Identity/OpenIddict entities. - public class OpenIddictContext : OpenIddictContext, - OpenIddictAuthorization, - OpenIddictScope, - OpenIddictToken, - IdentityRole, TKey> + public class OpenIddictContext : OpenIddictContext, OpenIddictApplication, + OpenIddictAuthorization, + OpenIddictScope, + OpenIddictToken, TKey> where TUser : OpenIddictUser where TKey : IEquatable { /// @@ -75,19 +73,44 @@ namespace OpenIddict { /// Represents an OpenIddict-powered Entity Framework context. /// /// The type of the User entity. + /// The type of the Role entity. + /// The type of the primary key used by the Identity/OpenIddict entities. + public class OpenIddictContext : OpenIddictContext, + OpenIddictAuthorization, + OpenIddictScope, + OpenIddictToken, TKey> + where TUser : OpenIddictUser + where TRole : IdentityRole + where TKey : IEquatable { + /// + /// Initializes a new OpenIddict context without configuring the Entity Framework options. + /// + protected OpenIddictContext() { } + + /// + /// Initializes a new OpenIddict context. + /// + /// The options used to configure the Entity Framework context. + public OpenIddictContext(DbContextOptions options) : base(options) { } + } + + /// + /// Represents an OpenIddict-powered Entity Framework context. + /// + /// The type of the User entity. + /// The type of the Role entity. /// The type of the Application entity. /// The type of the Authorization entity. /// The type of the Scope entity. /// The type of the Token entity. - /// The type of the Role entity. /// The type of the primary key used by the Identity/OpenIddict entities. - public class OpenIddictContext : IdentityDbContext + public class OpenIddictContext : IdentityDbContext where TUser : OpenIddictUser + where TRole : IdentityRole where TApplication : OpenIddictApplication where TAuthorization : OpenIddictAuthorization where TScope : OpenIddictScope where TToken : OpenIddictToken - where TRole : IdentityRole where TKey : IEquatable { /// /// Initializes a new OpenIddict context without configuring the Entity Framework options.