No executable found matching command "dotnet-aspnet-codegenerator" asp.net core 2.1 project in mac

After binging through various sites and using the help of senior developers, I was finally able to fix the issue. I found that code generation tool, used for scaffolding of model, became a global .NET Core CLI tool in the 2.1 release. So, instead of just adding package reference it should be installed globally. For more details refer to https://github.com/aspnet/Docs/issues/6894. The command to install code generation tool globally is:

dotnet tool install --global dotnet-aspnet-codegenerator

It will install latest version of code generation tool.