Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PasswordSignInAsync. ArgumentNullException: Value cannot be null

I'm using the following code to sign in a user:

public async Task<RepositoryResponse> PasswordSignInAsync(string userName, string password, bool isPersistent,
    bool lockoutOnFailure)
{
    var signInResult = await _signInManager.PasswordSignInAsync(userName, password, isPersistent, lockoutOnFailure);

    return GetResponseBySignInResult(signInResult);
}

I'm getting an exception that originates from the PasswordSignInAsync method, as shown here:

ArgumentNullException: Value cannot be null. Parameter name: entityType Microsoft.Data.Entity.Utilities.Check.NotNull[T](T value, String parameterName)

I'm using Identity 3, MVC6 and Entity Framework 7.

like image 222
Rhys Avatar asked May 06 '26 09:05

Rhys


1 Answers

I was having a similar problem that drove me nuts for ages... it's worth checking your user has a SecurityStamp that isn't null (setting it as a random string will work). Identity seems to not have a problem storing it as a null field in the database, but as soon as you need to do anything like log in it throws this exception.

That was my issue, hope it's the same for you and it works! (Despite how long ago this question was asked)

In the meantime, if anyone with more knowledge of Identity than I have stumbles across this and can explain the virtue of the SecurityStamp being nullable it might be worth an upvote or two.

like image 158
Tim Hirst Avatar answered May 09 '26 00:05

Tim Hirst



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!