0

I've made use of the administration tool to create users and roles. What I'm trying to do is create another table..

public class TaskModel
{
    public int Id { get; set; }
    public string Time { get; set; }
    public string Description{ get; set; }

    public class TaskDBContext : DbContext
    {
        public DbSet<TaskModel> Tasks { get; set; }
    }
}

..and create a foreign key to the UserId (Users table) and to the RoleId (Roles table) - (which are both automatically created by the admin tool). The site administration tool does not create models for the tables so I don't know how to point to it and create the foreign keys. (I believe this post described creating FK's between two different classfiles but I cannot apply it: How Should I Declare Foreign Key Relationships Using Code First Entity Framework (4.1) in MVC3?).

Also another question; I know how to display TaskModel records in a view, but how do I filter those results with the foreignkeys in it? What I mean is filter by UserId (logged in user) and/or RoleId? (this question is less important then question above).

Community
  • 1
  • 1
tutu
  • 673
  • 2
  • 13
  • 31

1 Answers1

1

You could write a custom membership provider that the website administration tool will use. In your custom membership provider, you will create the records in your extra table, and insert them into the users table when a user is created. If you need any special user interface for this, then you'll have to write your own user administration tool.

http://www.codeproject.com/Articles/165159/Custom-Membership-Providers

Erik Funkenbusch
  • 92,674
  • 28
  • 195
  • 291