@@ -27,7 +27,7 @@ protected IdentityDbContext() { }
2727 /// Base class for the Entity Framework database context used for identity.
2828 /// </summary>
2929 /// <typeparam name="TUser">The type of the user objects.</typeparam>
30- public class IdentityDbContext < TUser > : IdentityDbContext < TUser , string > where TUser : IdentityUser
30+ public class IdentityDbContext < TUser > : IdentityDbContext < TUser , IdentityRole , string > where TUser : IdentityUser
3131 {
3232 /// <summary>
3333 /// Initializes a new instance of <see cref="IdentityDbContext"/>.
@@ -41,27 +41,6 @@ public IdentityDbContext(DbContextOptions options) : base(options) { }
4141 protected IdentityDbContext ( ) { }
4242 }
4343
44- /// <summary>
45- /// Base class for the Entity Framework database context used for identity.
46- /// </summary>
47- /// <typeparam name="TUser">The type of user objects.</typeparam>
48- /// <typeparam name="TKey">The type of the primary key for users and roles.</typeparam>
49- public class IdentityDbContext < TUser , TKey > : IdentityDbContext < TUser , TKey , IdentityUserClaim < TKey > , IdentityUserLogin < TKey > , IdentityUserToken < TKey > >
50- where TUser : IdentityUser < TKey >
51- where TKey : IEquatable < TKey >
52- {
53- /// <summary>
54- /// Initializes a new instance of the db context.
55- /// </summary>
56- /// <param name="options">The options to be used by a <see cref="DbContext"/>.</param>
57- public IdentityDbContext ( DbContextOptions options ) : base ( options ) { }
58-
59- /// <summary>
60- /// Initializes a new instance of the class.
61- /// </summary>
62- protected IdentityDbContext ( ) { }
63- }
64-
6544 /// <summary>
6645 /// Base class for the Entity Framework database context used for identity.
6746 /// </summary>
@@ -85,99 +64,6 @@ public IdentityDbContext(DbContextOptions options) : base(options) { }
8564 protected IdentityDbContext ( ) { }
8665 }
8766
88- /// <summary>
89- /// Base class for the Entity Framework database context used for identity.
90- /// </summary>
91- /// <typeparam name="TUser">The type of user objects.</typeparam>
92- /// <typeparam name="TKey">The type of the primary key for users and roles.</typeparam>
93- /// <typeparam name="TUserClaim">The type of the user claim object.</typeparam>
94- /// <typeparam name="TUserLogin">The type of the user login object.</typeparam>
95- /// <typeparam name="TUserToken">The type of the user token object.</typeparam>
96- public abstract class IdentityDbContext < TUser , TKey , TUserClaim , TUserLogin , TUserToken > : DbContext
97- where TUser : IdentityUser < TKey >
98- where TKey : IEquatable < TKey >
99- where TUserClaim : IdentityUserClaim < TKey >
100- where TUserLogin : IdentityUserLogin < TKey >
101- where TUserToken : IdentityUserToken < TKey >
102- {
103- /// <summary>
104- /// Initializes a new instance of the class.
105- /// </summary>
106- /// <param name="options">The options to be used by a <see cref="DbContext"/>.</param>
107- public IdentityDbContext ( DbContextOptions options ) : base ( options ) { }
108-
109- /// <summary>
110- /// Initializes a new instance of the class.
111- /// </summary>
112- protected IdentityDbContext ( ) { }
113-
114- /// <summary>
115- /// Gets or sets the <see cref="DbSet{TEntity}"/> of Users.
116- /// </summary>
117- public DbSet < TUser > Users { get ; set ; }
118-
119- /// <summary>
120- /// Gets or sets the <see cref="DbSet{TEntity}"/> of User claims.
121- /// </summary>
122- public DbSet < TUserClaim > UserClaims { get ; set ; }
123-
124- /// <summary>
125- /// Gets or sets the <see cref="DbSet{TEntity}"/> of User logins.
126- /// </summary>
127- public DbSet < TUserLogin > UserLogins { get ; set ; }
128-
129- /// <summary>
130- /// Gets or sets the <see cref="DbSet{TEntity}"/> of User tokens.
131- /// </summary>
132- public DbSet < TUserToken > UserTokens { get ; set ; }
133-
134- /// <summary>
135- /// Configures the schema needed for the identity framework.
136- /// </summary>
137- /// <param name="builder">
138- /// The builder being used to construct the model for this context.
139- /// </param>
140- protected override void OnModelCreating ( ModelBuilder builder )
141- {
142- builder . Entity < TUser > ( b =>
143- {
144- b . HasKey ( u => u . Id ) ;
145- b . HasIndex ( u => u . NormalizedUserName ) . HasName ( "UserNameIndex" ) . IsUnique ( ) ;
146- b . HasIndex ( u => u . NormalizedEmail ) . HasName ( "EmailIndex" ) ;
147- b . ToTable ( "AspNetUsers" ) ;
148- b . Property ( u => u . ConcurrencyStamp ) . IsConcurrencyToken ( ) ;
149-
150- b . Property ( u => u . UserName ) . HasMaxLength ( 256 ) ;
151- b . Property ( u => u . NormalizedUserName ) . HasMaxLength ( 256 ) ;
152- b . Property ( u => u . Email ) . HasMaxLength ( 256 ) ;
153- b . Property ( u => u . NormalizedEmail ) . HasMaxLength ( 256 ) ;
154-
155- // Replace with b.HasMany<IdentityUserClaim>().
156- b . HasMany < TUserClaim > ( ) . WithOne ( ) . HasForeignKey ( uc => uc . UserId ) . IsRequired ( ) ;
157- b . HasMany < TUserLogin > ( ) . WithOne ( ) . HasForeignKey ( ul => ul . UserId ) . IsRequired ( ) ;
158- b . HasMany < TUserToken > ( ) . WithOne ( ) . HasForeignKey ( ut => ut . UserId ) . IsRequired ( ) ;
159- } ) ;
160-
161- builder . Entity < TUserClaim > ( b =>
162- {
163- b . HasKey ( uc => uc . Id ) ;
164- b . ToTable ( "AspNetUserClaims" ) ;
165- } ) ;
166-
167- builder . Entity < TUserLogin > ( b =>
168- {
169- b . HasKey ( l => new { l . LoginProvider , l . ProviderKey } ) ;
170- b . ToTable ( "AspNetUserLogins" ) ;
171- } ) ;
172-
173- builder . Entity < TUserToken > ( b =>
174- {
175- b . HasKey ( l => new { l . UserId , l . LoginProvider , l . Name } ) ;
176- b . ToTable ( "AspNetUserTokens" ) ;
177- } ) ;
178- }
179- }
180-
18167 /// <summary>
18268 /// Base class for the Entity Framework database context used for identity.
18369 /// </summary>
@@ -189,7 +75,7 @@ protected override void OnModelCreating(ModelBuilder builder)
18975 /// <typeparam name="TUserLogin">The type of the user login object.</typeparam>
19076 /// <typeparam name="TRoleClaim">The type of the role claim object.</typeparam>
19177 /// <typeparam name="TUserToken">The type of the user token object.</typeparam>
192- public abstract class IdentityDbContext < TUser , TRole , TKey , TUserClaim , TUserRole , TUserLogin , TRoleClaim , TUserToken > : IdentityDbContext < TUser , TKey , TUserClaim , TUserLogin , TUserToken >
78+ public abstract class IdentityDbContext < TUser , TRole , TKey , TUserClaim , TUserRole , TUserLogin , TRoleClaim , TUserToken > : IdentityUserContext < TUser , TKey , TUserClaim , TUserLogin , TUserToken >
19379 where TUser : IdentityUser < TKey >
19480 where TRole : IdentityRole < TKey >
19581 where TKey : IEquatable < TKey >
0 commit comments