【问题标题】:What's the difference between Microsoft.Extensions.Identity.Stores and Microsoft.Extensions.Identity.Core and Microsoft.AspNetCore.Identity?Microsoft.Extensions.Identity.Stores 和 Microsoft.Extensions.Identity.Core 和 Microsoft.AspNetCore.Identity 有什么区别?
【发布时间】:2020-03-19 14:13:36
【问题描述】:

我对 asp.net 核心标识中的三个包感到困惑。我不知道彼此之间有什么区别。还有我们应该使用哪一个?

我在 GitHub 上找到了这个链接,但我没有得到它。

Difference between Microsoft.Extensions.Identity.Stores and Microsoft.AspNetCore.Identity

【问题讨论】:

    标签: asp.net-core


    【解决方案1】:
    • Microsoft.Extensions.Identity.Core

    这个程序集包含了整个asp.net core Identity框架的实体定义,大致包括IdentityUser,IdentityRole,IdentityUserRole,IdentityUserClaim,IdentityRoleClaim,IdentityUserLogin。也可以这样理解作为数据库表。

    • Microsoft.Extensions.Identity.Stores

    这个程序集主要用于对以上实体进行基本的CRUD,包括用户管理(UserManager)和角色管理(RoleManager),以及一些可以进行的配置,比如用户名限制、密码验证, 等等。具体的存储实现需要下载其他包,比如Microsoft.AspNetCore.Identity.EntityFrameworkCore就是使用EF Core实现的数据存储。

    • Microsoft.AspNetCore.Identity

    此程序集用于管理 AspNetCore 项目中的身份验证和授权,还包括 AspNetCore 项目中的基本配置。比如要使用Identity框架,需要在ConfigureServices方法中执行services.AddIdentity <TUser> ()

    基础二次开发是基于以上核心包。如果希望asp.net core Identity支持其他ORM框架,比如Dapper,那么可以使用Microsoft.Extensions.Identity.Stores进行二次开发。或者如果一些业务 逻辑不满足你的特殊需求,也是用这个包开发的。

    如果要扩展字段,需要Microsoft.Extensions.Identity.Core包,并继承相关类。

    【讨论】:

    • 我刚刚下载了 Identity.Core 包,它似乎与您在此处所说的不同。所以我会考虑更新这个答案,因为 .NET Core Identity 3.1 似乎发生了一些变化。
    猜你喜欢
    • 1970-01-01
    • 2010-10-02
    • 2011-12-12
    • 2010-09-16
    • 2012-03-14
    • 2012-02-06
    • 2011-02-25
    • 2011-11-22
    • 2015-03-26
    相关资源
    最近更新 更多