Jonathan Wood
Jonathan Wood

Reputation: 67193

Configure database for MVC authentication

I've been Googling terms like

configure database for mvc authentication

But I can't find anything from this decade that relates to my configuration.

I've created an MVC application using .NET Framework 4.6 with authentication support (database first). Now where do I find step-by-step instructions for creating the database tables and configuring MVC to use them?

Thanks for any tips!

Upvotes: 0

Views: 407

Answers (1)

Andrew Shepherd
Andrew Shepherd

Reputation: 45252

The correct thing to google for is 'ASP.NET Identity'.

If you generate an MVC app straight from one of the templates it will generate a number of classes to handle security and identity.

One of these classes will implement interface IUserStore. The class provided will inherit from Microsoft.AspNet.Identity.EntityFramework.UserStore<TUser>, and uses Entity Framework to check the database if the tables exist, and create them if they are not there.

If you are uneasy about giving your application enough privileges to modify your data schema (ew!), you can create your own class that implements IUserStore and plug that into the system.

It's a big topic, but hopefully this is enough to get started with.

Upvotes: 1

Related Questions