skylake skylake - 26 days ago 5x
C# Question

Login first to access page - MVC Database-first

There are way to many code-first tutorial but I cannot find any good guide how to force user to register/login first to access the page via database-first solution.

Correct me if I'm wrong. As I've seen these code-first tutorial, they implement validations directly into EF-models. That way I may not be able to do for database-first solution, as everything will be removed once EF will re-create models once I update the database or so.

Is there any good guide how to do it?

Any help is much appreciate. Thanks.


As suggested in the comment; in order to force application to go to Login page first, you have to decorate your Main / Home controller with [Authorize] attribute.