Q:

How to get the data from aspnet_Membership, aspnet_Users and aspnet_UsersInRoles in aspnetDB?

I wanna ask how to get the datas in aspnet_Membership and aspnet_Users separately?? and even aspnet_UsersInRoles in C#?
I'll be using LINQ statement when I get the data from these aspnet tables.
Thank you so much.

A:

public class UsersContext : DbContext
{
    public UsersContext()
        : base("DefaultConnection")  // web.config
    {
    }

    public DbSet<UserProfile> UserProfiles { get; set; }
}

[Table("UserProfile")]
public class UserProfile
{
    [Key]
    [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
    public int UserId { get; set; }
    public string UserName { get; set; }
}

public class UserData
{
    private static List<UserProfile> _userList;

    public static List<UserProfile> userList
    {
        get
        {
            if (_userList == null)
            {
                UsersContext db = new UsersContext();
                _userList = db.UserProfiles.SqlQuery("select * from dbo.UserProfile").ToList();
            }
            return _userList;
        }
        set
        {
            _userList = value;
        }
    }
}

same way for membership, userinrole table

