I have a ASP.NET MVC4 project in which I would like to use the SimpleMembership. The application has a Person table that holds relevant information about users in the system.

I would like a link between the currently logged in user and the Person information. So I have made a foreign key in the Person table to the UserId column of UserProfile table (from SimpleMembership).

I use Entity Framework 5 as ORM and have implemented a generic repository to handle CRUD methods and so on.

Now I am at a point where I want to implement user profile creation. The creation consists of 2 parts parts:

  • login: username and password (to be stored in SimpleMembership tables)
  • personal information (to be stored in Person table)

In order to create a user I guess I need to:

  1. Save user information through SimpleMembership
  2. Save personal information together with userId from step 1 through my PersonRepository

I would like some kind of UserRepository that could save SimpleMembership data but I do not know if it's the right approach? Is there a better approach?

2 Answers 2


I always keep repositories so there a is a one to one relationship between a repository and a table in a database. And repositories do not know about other repositories. If you need to handle transactions between repositories I would implement a Unit of Work design pattern and on top of that a Service design pattern that handles the domain logic around the transactions.

Another option is to modify the UserProfile in SimpleMembership to contain the extra information that you have in the Person table. UserProfile was designed to be customized and you can read about customizing it here.

  • If I take the Unit of Work approach - how will data be inserted into the webpages_* tables? Would it be correct to use WebSecurity calls in my repository? Feb 28, 2013 at 9:57
  • You would not make WebSecurity calls from a repository. Those calls would be made from the Service layer. The WebSecurity API is a Service layer. Service layers can all other Service layers. You would wrap each of your custom tables in a repository. Then the repositories in a single unit of work, which is managed by a service layer. If your service layer is tightly coupled with the WebSecurity it could be called from this layer. Feb 28, 2013 at 14:17

You could wrap this functionality up as a service.

In the service you would use both the SimpleMembership api and your own repository code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.