Search code examples
asp.net-coreasp.net-core-mvcasp.net-identity-3

Identity error when to ASP.NET Core MVC RC2 upgrading from RC1


I have from my RC1 version:

           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();

and I am getting an error on the first line specifically this part of the line:

AddIdentity<User, Role>

The error is:

The call is ambiguous between the following methods or properties: 'Microsoft.Extensions.DependencyInjection.IdentityServiceCollectionExtensions.AddIdentity(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Action)' and '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 Active

I know this is bleeding edge but if there is anybody out there who might have an idea on this I am all ears..


Solution

  • Please check the other answers on StackOverflow, there is a dozen of question asking the exact same thing.

    Your issue is that you mix RC1 and RC2 libraries. This won't work! All of stack libraries (ASP.NET/MVC/EF/Identity) have to be 1.0.0-rc2-final, not 1.0.0-rc2-* or rc1. Read the annoncements, they have all the breaking changes in them.

    Often outdated package name is an issue (i.e. Microsoft.AspNet.Mvc is outdated and you have to use Microsoft.AspNetCore.Mvc, as the first one will drag old dependencies.

    Also some of your other dependencies (i.e. Swashbuckle.Swagger etc.) may still reference old rc1 libraries. They all need to be upgraded to the latest rc2 builds.

    The error message you are getting is because two assemblies with different name are referenced and both have the same extension method in the same namespace so the compiler doesn't know which one to choose.