Method not found: Void Microsoft.EntityFrameworkCore.Design. Internal.DbContextOperations

I was working on this Core application and got this error below while trying to scaffold a new controller as seen below. I suspected the issue happened because I had updated a few packages in the project.
Scaffolding new controller core Microsoft.EntityFrameworkCore.Design

Error message

Method not found: 'Void Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations..ctor
(Microsoft.EntityFrameworkCore.Design.Internal.IOperationReporter, System.Reflection.Assembly, System.Reflection.Assembly)'.
   at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.b__6_0()
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args)
   at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)


After a quick searching and reading a few post online, I stumbled upon this one post on Stackoverflow where someone had similar issue. So, below you will find exactly what I did to resolve that issue which was very simple.

  • I unload the project, Right click the project -> Unload Project
  • Next, Right click the unloaded project name and Edit the .csproj file
  • Find the ItemGroup section in the .csproj file as seen below and update the following
      <PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
      <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.7" />
      <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.3" />
      <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.3" PrivateAssets="All" />
      <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.3" PrivateAssets="All" />
  • Once done updating the versions, right click the project name and reload it. Then, clean the solution and build the project afterwards. If this doesn’t work for you then downgrade to a lower version until you get it to work.

Leave a Reply

Your email address will not be published. Required fields are marked *