This project is read-only.

Identity Entities Usage

Feb 16, 2014 at 12:14 PM
Hi there,
How can I use implemented entities of aspnet identity in my application scope?
For example, identity has created "dbo.aspnetRoles" table in database and I want to use that table to join with something like myCustomClass in my DefaultContext (my main application context).
 public class DefaultContext : DbContext, 
        public DefaultContext()
            : base("DefaultConnection"){ }
        public DbSet<aspnetRoles> Roles { get; set; }

  public class myCustomClass
        List<aspnetrole>  ... ?
Is that possible ?
Feb 19, 2014 at 10:00 PM
It is possible to reference the Roles class in your custom class by having a reference to it via foreign key. You need to follow EF conventions to do that.

public class MyClass {
public virtual IList<IdentityRole> MyRoles{get;set;}

The virtual keyword should do the trick.