Visual Studio ASP.NET MVC controller with views and EF template creates db.ApplicationUsers instead of just db.Users.
Workaround summary:
1. Rename ApplicationUsers to Users
2. Delete the Controller and View
3. Close and Re-open VS and Project. Rebuild.
4. Recreate the Controller!
So its in the morning, you said lets scaffold! And you got this error:
This happens when you reference a foreign key your “ApplicationUsers” that is used in the IdentityDbContext that inherits IdentityUser.
And then when you add a new controller with views using EF the scaffold will generate the ApplicationUsers but its DbSet or property of the object will not be available.
One workaround is to rename your ApplicationUsers to only “Users”.
Now this is important, delete the controller and its views folder after renaming. Then you need to close visual studio.
Open the project once more and rebuild your solution.
You should now be able to scaffold the controller.
Happy Scaffoldings!