3

I am building a WebApi2 project and wanted to use mongodb as a backend and I found MongoDB.AspNet.Identity package, I used it before in MVC5 website and it worked well, but after installing in the WebApi project I got an error: enter image description here

Error 1 The type or namespace name 'IdentityUserLogin' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs

How to fix that? or it is impossible to use MongoDB.AspNet.Identity package with WebApi2 projects?

2 Answers 2

7

Change every occurence of IdentityUserLogin to UserLoginInfo. Furthermore change

user.Logins.Add(new UserLoginInfo
        {
            LoginProvider = externalLogin.LoginProvider,
            ProviderKey = externalLogin.ProviderKey
        });

to

user.Logins.Add(new UserLoginInfo(
            externalLogin.LoginProvider,
            externalLogin.ProviderKey
        ));

Should work now.

Sign up to request clarification or add additional context in comments.

Comments

2

You mean replace,

user.Logins.Add(new IdentityUserLogin 
{
  LoginProvider = externalLogin.LoginProvider,
  ProviderKey = externalLogin.ProviderKey
});

to

user.Logins.Add(new UserLoginInfo(
        externalLogin.LoginProvider,
        externalLogin.ProviderKey
));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.