如何使用 identity 2.2 而不要在 ApplicationUserManager 上使用 ILookupNormalizer

How to use identity 2.2 and don't use ILookupNormalizer on ApplicationUserManager

如何删除 identity core3 preview4 中的任何 ILookupNormalizer 注入?

我使用 identity 2.2,无法在 ApplicationUserManager 上使用 ILookupNormalizer。 我的挛缩 ApplicationUserManager :

public ApplicationUserManager(
            IApplicationUserStore store,
            IOptions<IdentityOptions> optionsAccessor,
            IPasswordHasher<TblUsers> passwordHasher,
            IEnumerable<IUserValidator<TblUsers>> userValidators,
            IEnumerable<IPasswordValidator<TblUsers>> passwordValidators,
            ILookupNormalizer keyNormalizer,
            IdentityErrorDescriber errors,
            IServiceProvider services,
            ILogger<ApplicationUserManager> logger,
            IHttpContextAccessor contextAccessor,
            IUsedPasswordsService usedPasswordsService)
            : base((UserStore<TblUsers, TblOrganizationChart, AbfaContext, int, TblUserClaim, TblUserOrganizationChart, TblUserLogin, TblUserToken, TblRoleClaim>)store, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, services, logger)

当我在 AddCustomServices 上添加 ILookupNormalizer 时,出现此错误:

Method 'NormalizeName' in type 'Project.Core.Identity.CS.CustomNormalizers' from assembly 'Project.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.

删除后 "services.AddScoped();" 我有这个错误:

'Method 'NormalizeKey' in type 'Project.Core.Identity.ApplicationUserManager' from assembly 'Project.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.'

我不需要使用 Normalizer。

如何解决?

身份核心 3x is different than the 2x. If you want to continue using your old project and you don't want to upgrade it yet (according to the title of your question), just lock the framework version of your solution by using a global.json 文件中 ILookupNormalizer 的签名。先用运行dotnet --list-sdks命令查看安装了哪些版本。然后使用 dotnet new globaljson --sdk-version 2.2.106 命令在您的解决方案的根目录中创建一个新的。

dotnet --list-sdks
dotnet new globaljson --sdk-version 2.2.106