I have resolved this issue by updating all the NuGet packages to the latest stable version 9 and cleaning and rebuilding my project. But unfortunately, whenever I use scaffolding I face some issues.