What does The non-generic method cannot be used with type arguments mean in this context?

As the error says, FindByIdAsync does not take type parameters. These exist on the declaring class UserManager<TUser, TKey>

var user = await UserManager.FindByIdAsync(99);

The method is declared as:

public virtual Task<TUser> FindByIdAsync(TKey userId);

And not :

public virtual Task<TUser> FindByIdAsync<T, U>(TKey userId);

The method is not generic, so you cannot pass types when calling it.

The fix is by calling it without the types:

var user = await UserManager.FindByIdAsync(99);

Tags:

C#