How do I use an existing database in an ASP.NET MVC C# and Identity application?

Asked

Viewed 266 times

2

I need to authenticate users.

So I created my database with all my business rules, connected to the ASP.NET MVC application, and started programming.

Now, when I went to do the login user realized that there are two connections, one call DefaultConnection and my of SQLServer.

The question is: how to change ASP.NET Identity so I can only use the connection to my local database?

1 answer

0


Of the two:

  • Or redo the login part accessing your tables from your database.

  • Or you add ASP.NET Identity as an auxiliary database in the same SQL instance that accesses your database.

The first option seems complicated but it is not, and allows you total control over your Logins and Roles.

I opted for the second one because I had the project practically done already working on Identity.

  • I didn’t understand how this first option would work.

  • You have to study the Controllers from the part where Identity is used and get the same information from your database. For example the Login or Register Controllers, instead of fetching the user and the password from Identity you have to fetch from your BD.

  • Thank you! I think I understand how it’s done. I used the Identity model as a Viewmodel and in my Controller I received it from the model and saved it in my database.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.