Closed ghost closed 6 years ago
@ckams Using new
in that way creates a new property that hides the one on the base class. So there are now two independent properties, both with the same name. Code will use one or the other based on which type it is compiled against. Since the Identity code is not compiled against your types, it will never use or set your new property. But EF is still trying to persist it, and since there is no value set there is an exception.
@ajcvickers Not obvious, even very weired… I find this very buggy, like a lot of things with Identity/Efcore…
Anyway, I tried to override these properties in this app for translation purpose…
So how can I localize this properties?
@ckams Overriding (public override string ClaimType { get; set; }
) should work fine. Hiding with new
is very different. Using new
in this way is quite uncommon.
I get this kind of error:
When I try to override any property of IdentityXXX class, like for example
IdentityRoleClaim<TKey>
:and then try to get the user in
AuthorizationHandler
class:var user = await _userManager.GetUserAsync(context.User);
Without overriding, everything works as expected.
This project uses Microsoft ASP.NET Core 2.1.2 Microsoft EntityFrameworkCore 2.1.1