Error: There was an error runnig the selected code generator: 'Method not found...' c# entity-framework-core


I working on my small .NET Core 2.0 MVC Project. What i want to do is to generate read/write controller with views but when it scafolding, i have an error:

enter image description here enter image description here

I'm using:

  • Microsoft.AspNetCore.All v2.0.8
  • EFCore v2.2.0
  • EFCore.SqlServer v2.2.0
  • EfCore.Tools v2.2.0
  • Microsoft.NETCore.App v2.0.0
  • Microsoft.VS.Web.Code.Generation.Design v2.0.4
  • Npgsql.Entity.Framework.Core.postgreSQL v.2.1.2 (my friend that i work with have local db set up in Postgre)

My database is set up corectly on LocalDB.


namespace Farm.Models
public class FarmDbContext : DbContext
    public FarmDbContext(DbContextOptions<FarmDbContext>
        options) : base(options) { }

    public DbSet<Farm>         Farms          { get; set; }
    public DbSet<Animal>       Animals        { get; set; }
    public DbSet<Cultivation>  Cultivations   { get; set; }
    public DbSet<Dairy>        Dairies        { get; set; }
    public DbSet<Grain>        Grains         { get; set; }
    public DbSet<Machine>      Machines       { get; set; }
    public DbSet<MilkQuantity> MilkQuantities { get; set; }
    public DbSet<Silo>         Silos          { get; set; }
    public DbSet<Species>      Species        { get; set; }
    public DbSet<Worker>       Workers        { get; set; }

Part of Startup.cs

public void ConfigureServices(IServiceCollection services)
        services.AddDbContext<FarmDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));


For example, my Farm.cs Model:

namespace Farm.Models
public class Farm
    public int    Id                      { get; set; }
    public string Localization            { get; set; }

    public List<Animal>      Animals      { get; set; }
    public List<Worker>      Workers      { get; set; }
    public List<Machine>     Machines     { get; set; }
    public List<Silo>        Silos        { get; set; }
    public List<Cultivation> Cultivations { get; set; }

When i want to just generate View automatically (for example, Create) from any model, i get the same error. How to repair that?


When i upgraded Microsoft.VisualStudio.Web.CodeGeneration.Design to ver 2.2.0, scafolding works longer than before and i get this error:

enter image description here

12/6/2018 6:05:19 PM

Accepted Answer

Problem solved:

  • Upgraded VIsual Studio 2017 to ver. 15.9.3 (i had 15.7)
  • Downgrade NETCore.App and AspNetCore.ALL to ver 2.1
  • Change project target to Net Core 2.1

Now, generating controllers with views works perfectly

12/6/2018 7:13:16 PM

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