Peadar Doyle
Peadar Doyle

Reputation: 1112

Custom membership provider or role my own implementation

I've started using the membership provider in a new asp.net mvc project. My membership model is quite dissimilar to the default model but I assumed I could customize it to my liking. It seams though that I'm creating a custom implementation for everything I'm doing.

My model has two types (inheriting from the same base) of User entities and a Customer entity.

public class Customer
{
    /* properties go here */

    // users linked with this customer
    public virtual IList<TypeOneUser> TypeOneUsers { get; set; }
    public virtual IList<TypeTwoUser> TypeTwoUsers { get; set; }
}

public abstract class User
{
    /* user properties go here */
}

public class TypeOneUser: User
{
    public virtual IList<Customer> Customers { get; set; }
}

public class TypeTwoUser: User
{
    public virtual Customer Customer { get; set; }
}

I'm currently considering just implementing a Customer repository and User repository and scrapping the membership provider. So my question is, is there a straight forward way to implement my membership model with the membership provider? At the moment I have the User classes mostly implemented with a custom membership provider but I'm not sure how to integrate the Customer entity with the membership provider.

Also I'm using Fluent Nhibernate so I'm writing my own persistence code regardless of my approach.

Upvotes: 3

Views: 466

Answers (1)

TehBoyan
TehBoyan

Reputation: 6890

You can take a look at my blog post on creating a custom membership provider. There is an example there, it uses Linq-to-Sql but I think it can give you a pretty good idea on how you can use your model to persist the data in the database.

Upvotes: 2

Related Questions