Okay so I have a MVC project that auto generates an AccountController AcountModel and the associated views.
I created a database with 3 tables using the model first approach, and generated all the controllers/views for all the CRUD operations.
The database contains a user table with a user id, email and password.
How can I use this user table with the auto generated AccountController for user login and registration?
I will show you registration process only , refering which you can build your login/registration with custom database.
Models:
You will add your custommodel to the
AccountModels.cs, So it will have following details:Context:
You will add custom context to the
Modelsas below:Controller:
Now we will modify our
AccountControllerfor registration as below:EDIT web.config:
Finally, you will have to add the new context to the connectionstrings as below:
You can change the database name to whatever you want and put it as your convenience but put the path here correctly.
Hope you have got the idea now…