public class AppUser: Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser<long>
{
public List<AspNetUserClient> Clients { get; set; }
}
public class AspNetUserClient
{
[Key]
public long ID { get; set; }
/// <summary>
/// this object is from IdentityServer4.Entityframework
/// </summary>
public IdentityServer4.EntityFramework.Entities.Client ClientID { get; set; }
public AppUser AppUserID { get; set; }
}
I want make a relationship between IdentityUser and IdentityServer Client.
IdentityUser can create clients, what the best solution?
Help!!
@brockallen / @leastprivilege
I'm unclear on what's being asked.
If they want to setup some additional FKs in their DB, then go for it. But that's beyond the scope of either IdentityServer or ASP.NET Identity, I'd think.
@brockallen / @leastprivilege I think you get the point. I have tried lots of time, but still can not find the way.
Could you give me a example, thanks a lot!
public class AppUsersController : Controller
{
private readonly ApplicationDbContext _context;
public AppUsersController(ApplicationDbContext context)
{
_context = context;
}
// GET: AppUsers
public async Task<IActionResult> Index()
{
var users = await _context.Users
.Include(x => x.Logins)
.Include(x => x.Claims)
.Include(x => x.Roles)
// the point is here!! how to make this?
.Include(x => x.Clients)
.AsNoTracking()
.ToListAsync();
return View(users);
}
}
public class ApplicationDbContext : IdentityDbContext<AppUser,AppRole,long>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
}
public DbSet<AppUser> AppUser { get; set; }
}
public class AppUser : IdentityUser<long>
{
public long ParentUserID { get; set; }
}
I have achieved this by forking IdentityServer4.EntityFramework into my solution and extending it's entities right there. Looks a bit ugly but I don't know if there is better solution to extend IdentityServer's entities.
@jansivans can share me a link?
And I think it is better to extend Identity's entities, clients belong users,.user can create client.
As this is related to IdentityServer closing.