I'm developing a asp.net MVC webapp and scaffolding a controller with entity framework when getting this error
There was an error running the selected code generator:
'Exception of type 'System.InvalidOperationException' was thrown.'
Output console:
Finding the generator 'controller'...
Running the generator 'controller'...
Minimal hosting scenario!
Exception of type 'System.InvalidOperationException' was thrown.
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.\<BuildCommandLine\>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)
I updated all NuGet package and .Net SDK to latest version, but it didn't work. What should I do to fix it
I have fixed it. The issue was caused by adding both NuGet packages: Microsoft.AspNetCore.Identity.EntityFrameworkCore
and Microsoft.AspNetCore.Identity
. The tools didn’t know which IdentityUser to use for scaffolding. By deleting the lower version of the NuGet package, the problem was resolved.