Method not found: 'System.Reflection.MethodInfo Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.get_SelectAsyncMethod()'

.net-core entity-framework-core identityserver4


People I need help I am in a new project in which I am implementing identity server 4 and I am trying to recover the previously created users with asp.Identity that I have in my database to be able to verify when I make an external login from identity server 4. Sorry my english. My Startup.cs

public class Startup

public IConfiguration Configuration { get; }

public Startup(IConfiguration configuration)
    Configuration = configuration;

 public void ConfigureServices(IServiceCollection services)
    #region --Identity ASP

    services.AddDbContext<QGoodDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")),ServiceLifetime.Transient);
    services.AddIdentity<ApplicationUser, ApplicationRole>()




    // configure identity server with in-memory stores, keys, clients and scopes

When I initialize my database I already have this error

 public void Configure(IApplicationBuilder app, IHostingEnvironment env)

            if (env.IsDevelopment())


        private void InitializeDatabase(IApplicationBuilder app)
            using (var serviceScope = app.ApplicationServices.GetService<IServiceScopeFactory>().CreateScope())

                var context = serviceScope.ServiceProvider.GetRequiredService<QGoodDbContext>();


In my AccountController i have exception when call await _userManager.FindByLoginAsync(provider, providerUserId);

 public class AccountController : Controller
        private readonly UserManager<ApplicationUser> _userManager;
        private readonly SignInManager<ApplicationUser> _signInManager;
        private readonly QGoodDbContext _context;
        private readonly TestUserStore _users;
        private readonly IIdentityServerInteractionService _interaction;
        private readonly IClientStore _clientStore;
        private readonly IAuthenticationSchemeProvider _schemeProvider;
        private readonly IEventService _events;

        public AccountController(
            UserManager<ApplicationUser> userManager,
            SignInManager<ApplicationUser> signInManager,
            QGoodDbContext context,
            IIdentityServerInteractionService interaction,
            IClientStore clientStore,
            IAuthenticationSchemeProvider schemeProvider,
            IEventService events,
            TestUserStore users = null)
            // if the TestUserStore is not in DI, then we'll just use the global users collection
            // this is where you would plug in your own custom identity management library (e.g. ASP.NET Identity)
            _users = users ?? new TestUserStore(TestUsers.Users);
            _userManager = userManager;
            _signInManager = signInManager;
            _context = context;
            _interaction = interaction;
            _clientStore = clientStore;
            _schemeProvider = schemeProvider;
            _events = events;
          public async Task<IActionResult> ExternalLoginCallback()
                // read external identity from the temporary cookie
                var result = await HttpContext.AuthenticateAsync(IdentityServer4.IdentityServerConstants.ExternalCookieAuthenticationScheme);
                if (result?.Succeeded != true)
                    throw new Exception("External authentication error");

                // lookup our user and external provider info
                var (userTest, provider, providerUserId, claims) = FindUserFromExternalProvider(result);
                var user = await _userManager.FindByLoginAsync(provider, providerUserId);

Exception is:

Method not found: 'System.Reflection.MethodInfo Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.get_SelectAsyncMethod()'

10/31/2018 11:36:04 AM

Accepted Answer

I don't know what was the real problem but after downgrade Microsoft.EntityFrameworkCore.Tools to version 2.1.4 and updgrade again to last version problem gone.

11/5/2018 11:28:38 AM

Popular Answer

Hi can you show your packages install ? I have same problem too when i use EFCore. I solved this when I installed package


Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow