【问题标题】:Identity error when to ASP.NET Core MVC RC2 upgrading from RC1从 RC1 升级到 ASP.NET Core MVC RC2 时的身份错误
【发布时间】:2016-05-25 12:26:57
【问题描述】:

我的 RC1 版本有:

           services.AddIdentity<User, Role>(options =>
        {
            // configure identity options
            options.Password.RequireDigit = false;
            options.Password.RequireLowercase = false;
            options.Password.RequireUppercase = false;
            options.Password.RequiredLength = 3;
            options.User.AllowedUserNameCharacters = null;
        })
                      .AddEntityFrameworkStores<JobsDbContext, int>()
                      .AddUserStore<UserStore<User, Role, JobsDbContext, int>>()
                      .AddRoleStore<RoleStore<Role, JobsDbContext, int>>()
                      .AddDefaultTokenProviders();

我在第一行特别是该行的这一部分遇到错误:

AddIdentity<User, Role>

错误是:

以下方法或属性之间的调用不明确:“Microsoft.Extensions.DependencyInjection.IdentityServiceCollectionExtensions.AddIdentity(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Action)”和“Microsoft.Extensions.DependencyInjection.IdentityServiceCollectionExtensions.AddIdentity( Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Action)' JobsLedger..NETCoreApp,Version=v1.0 C:\Users\simon\DEV\JobsLedger-RC2-FIrstAttempt\src\JobsLedger\Startup.cs 64 活动

我知道这是最前沿的,但如果有人可能对此有想法,我会全力以赴..

【问题讨论】:

  • 没有 MVC 6 rc2。它现在只是称为 ASP.NET Core MVC

标签: asp.net-core asp.net-core-mvc asp.net-identity-3


【解决方案1】:

请查看 StackOverflow 上的其他答案,有十几个问题都在问完全相同的问题。

您的问题是您混合了 RC1 和 RC2 库。这行不通!所有堆栈库 (ASP.NET/MVC/EF/Identity) 都必须是 1.0.0-rc2-final、not 1.0.0-rc2-* 或 rc1。 阅读annoncements,其中包含所有重大变化。

通常过时的包名称是一个问题(即Microsoft.AspNet.Mvc 已过时,您必须使用Microsoft.AspNetCore.Mvc,因为第一个会拖累旧的依赖项。

您的一些其他依赖项(即 Swashbuckle.Swagger 等)可能仍会引用旧的 rc1 库。它们都需要升级到最新的 rc2 版本。

您收到的错误消息是因为引用了两个具有不同名称的程序集,并且它们在同一命名空间中具有相同的扩展方法,因此编译器不知道该选择哪一个。

【讨论】:

  • 发现我在 User.GetUserID() 上遇到错误,当您要求潜在的修复时,它希望添加 RC1 依赖项,从而导致混淆,从而导致错误。
猜你喜欢
  • 2016-09-20
  • 1970-01-01
  • 2020-01-25
  • 2016-04-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-02
相关资源
最近更新 更多