I started working with Entity Framework and I have one BIG problem. I want a many-to-many relation between entities User and Role.
So I created 3 tables User, Role, UserRoles

Next I created 3 entities:
public class User
{
public virtual int UserId { get; protected set; }
public virtual string UserName { get; set; }
public virtual string Password { get; set; }
public virtual DateTime CreateDate { get; set; }
public virtual ICollection<UserRole> Roles { get; set; }
public virtual ICollection<UserRole> CreatedRoles { get; set; }
}
public class Role
{
public virtual int RoleId { get; protected set; }
public virtual string Name { get; set; }
}
public class UserRole
{
public virtual int UserRoleId { get; protected set; }
public virtual int UserId { get; set; }
public virtual User User { get; set; }
public virtual int RoleId { get; set; }
public virtual Role Role { get; set; }
public virtual DateTime CreateDate { get; set; }
public virtual int CreateUserId { get; set; }
public virtual User CreateUser { get; set; }
}
I want to separate mapped user from created user. And In this step Entity Framework start to throw a bugs.
Next I want navigate from User object to his mapped roles and to his created mappings.
Can I configure Entity Framework to do these things?