At the moment, ApiAuthorizationDbContext<TUser>
force TUser
to extends IdentityUser
instead of IdentityUser<TKey>
. This means it is impossible to use Identity Server on application with ApplicationUser : IdentityUser<Guid>
(or anything different from IdentityUser<string>
)
Steps to reproduce the behavior:
IdentityUser<Guid>
instead of IdentityUser
The type 'WebApplication.Models.ApplicationUser' cannot be used as type parameter 'TUser' in the generic type or method 'ApiAuthorizationDbContext<TUser>'. There is no implicit reference conversion from 'WebApplication.Models.ApplicationUser' to 'Microsoft.AspNetCore.Identity.IdentityUser'.
I would expect ApiAuthorizationDbContext
to accept another generic to indicate the key type (e.g. ApiAuthorizationDbContext<ApplicationUser, Guid>
)
@HaoK @blowdart Where does ApiAuthorizationDbContext
come from?
Part of the identity server support I believe. @javiercn ?
ApiAuthorizationDbContext is just a convenience class for the templates.
We don鈥檛 plan to support all the variants IdentityDbContext supports.
If you want to customize the key you can extend IdentityDbContext directly and implement IPersistentGrantDbContext as ApiAuthorizationDbContext does.
Re-opening, since ApiAuthorizationDbContext
doesn't follow best practices for a DbContext
shipped for others to use. In particular:
DbContextOptions<TContext>
. Otherwise people resolving this directly will have issues when multiple contexts are registered in D.I.DbContextOptions
for use when other classes inherit from it.@javiercn Is this the correct repo to track this issue? If not, where should I move it?
@ajcvickers This is the correct repo.
Could we use a separate issue to track the items you mention?
2020 Looks like it was not fixed yet...
Am I wrong?
@blowdart , @ajcvickers - Would you accept a PR from the community on this one? I have opened up #21100 that should hopefully address everything. Thanks for your consideration.
We've decided not to support this
The idea is that apps can derive from IdentityDbContext directly and utilize the generic support there, this class is just meant to be sugar for the most common scenario
Most helpful comment
2020 Looks like it was not fixed yet...
Am I wrong?