3
votes

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.

1
I'm in the same boat right now. It's seeming like it would be easier to role my own membership service as opposed to trying to implement a custom MembershipProvider.blachniet
That's the way I ended up going. I have my own membership service working now and am currently implementing my own role service which looks to integrate with the authentication classes quite easily.Peadar Doyle
I gave up at begining of my project. I thought that there will be a lot of implementing so I'm using standart providers without my plannings. I have a deadline you know. But I'm very interested in this topic, if someone gives a quality answer, I'll be appreciated.oruchreis

1 Answers

2
votes

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.