You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
3 months ago | |
|---|---|---|
| .. | ||
| LINGYUN/Abp/Identity/EntityFrameworkCore | 4 months ago | |
| FodyWeavers.xml | 4 years ago | |
| FodyWeavers.xsd | 4 years ago | |
| LINGYUN.Abp.Identity.EntityFrameworkCore.csproj | 3 months ago | |
| README.EN.md | 1 year ago | |
| README.md | 1 year ago | |
README.md
LINGYUN.Abp.Identity.EntityFrameworkCore
身份认证EntityFrameworkCore模块,提供身份认证相关的数据访问实现。
功能特性
- 扩展Volo.Abp.Identity.EntityFrameworkCore.AbpIdentityEntityFrameworkCoreModule模块
- 提供身份认证相关的EF Core仓储实现
- 支持用户头像URL扩展属性的数据库映射
- 提供组织单元的EF Core仓储实现
- 提供会话管理的EF Core仓储实现
模块引用
[DependsOn(
typeof(AbpIdentityDomainModule),
typeof(Volo.Abp.Identity.EntityFrameworkCore.AbpIdentityEntityFrameworkCoreModule))]
public class YouProjectModule : AbpModule
{
// other
}
仓储实现
- EfCoreIdentityUserRepository - 用户仓储实现
- EfCoreIdentityRoleRepository - 角色仓储实现
- EfCoreIdentitySessionRepository - 会话仓储实现
- EfCoreOrganizationUnitRepository - 组织单元仓储实现
基本用法
- 配置DbContext
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAbpDbContext<IdentityDbContext>(options =>
{
options.AddRepository<IdentityRole, EfCoreIdentityRoleRepository>();
options.AddRepository<IdentityUser, EfCoreIdentityUserRepository>();
options.AddRepository<IdentitySession, EfCoreIdentitySessionRepository>();
options.AddRepository<OrganizationUnit, EfCoreOrganizationUnitRepository>();
});
}
- 使用仓储
public class YourService
{
private readonly IRepository<IdentityUser, Guid> _userRepository;
private readonly IRepository<IdentityRole, Guid> _roleRepository;
public YourService(
IRepository<IdentityUser, Guid> userRepository,
IRepository<IdentityRole, Guid> roleRepository)
{
_userRepository = userRepository;
_roleRepository = roleRepository;
}
public async Task<IdentityUser> GetUserAsync(Guid id)
{
return await _userRepository.GetAsync(id);
}
public async Task<IdentityRole> GetRoleAsync(Guid id)
{
return await _roleRepository.GetAsync(id);
}
}
数据库迁移
- 添加迁移
dotnet ef migrations add Added_Identity_Tables
- 更新数据库
dotnet ef database update