In my case, I had generated DbContext from an existing database. I had my connection string set in appSettings.json
file; however, when I generated the class files by scaffolding the DbContext class it had incorrect connection string.
So make sure your connection string is proper in appSettings.json
file as well as in DbContext
file. This will solve your issue.