EntityFrameworkCore RoleManager FindByIdAsync可以填充声明吗?

时间:2016-10-29 01:17:27

标签: c# entity-framework entity-framework-core asp.net-core-middleware asp.net-core-identity

在致电Microsoft.AspNetCore.Identity.RoleManager<Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole> github link to method

时,

Claims未填充FindByIdAsync(string id)媒体资源

AddEntityFrameworkStoresservices.AddIdentity的{​​{1}}可以启用eager loading吗?

public void ConfigureServices(IServiceCollection services){...}

1 个答案:

答案 0 :(得分:0)

克隆/分叉https://github.com/aspnet/Identity并在RoleStore中使用.Include(...)添加扩展方法暂时有用。

public virtual Task<TRole> GetByIdAsync(string id, CancellationToken cancellationToken = default(CancellationToken))
{
        cancellationToken.ThrowIfCancellationRequested();
        ThrowIfDisposed();
        var roleId = ConvertIdFromString(id);
        return Roles.Include(r => r.Claims).Include(r => r.Users).FirstOrDefaultAsync(u => u.Id.Equals(roleId), cancellationToken);
}