User authentication using Entity Framework in ASP.NET MVC 3

2.8k Views Asked by At

I have an enter image description hereexisiting database which I used to create a Model usign the Database first approach. Please refer to the database diagram.

In my solution file, I have a Class Library of the model which has an ADO.NET connection to the database & and I a ASP.NET MVC 3 web application.

The funcitonality that I'm trying to get here is that - the information displayed once a user logs in is different for every user. How do I link the user login page to the 'user' table of the database? Is it directly using the connection string or do I need to go through the model that I created using the Database?

1

There are 1 best solutions below

6
On BEST ANSWER

Add a field to your User table called "ProviderUserKey" or MembershipUserID, or something similar of type uniqueidentifier. You then call Membership.GetUser().ProviderUserKey and use that in your where clause of your User Table to select the correct User record based on the logged in user.