jjzjj

IdentityUser

全部标签

c# - 为什么 IdentityUser 类在 Microsoft.AspNet.Identity.EntityFramework 命名空间中而不是在 Core 包中?

为什么是IdentityUserMicrosoft.AspNet.Identity.EntityFramework中的类包而不是包含在Microsoft.AspNet.Identity.Core中包?为什么要依赖EntityFramework?这似乎是一个简单的类。我错过了什么?我通常将数据层与我的DAL分开。添加对EntityFramework的依赖对于IdentityUser类似乎有点多。 最佳答案 Identity的核心设计与EF或任何特定形状的用户和角色类型无关。一切都被商店抽象化了。事实上,对于任何给定的持久性提供者,类型

c# - MVC 5 : Should I inherit my User from IdentityUser class?

我正在尝试学习Asp.NetIdentity和在这个tutorial,在Models\AppModels,cs部分创建EntityFramework代码优先ToDo模型MyUser类(class)继承自IdentityUser类和MyDbContext继承自IdentityDbContext类(class)。这是为什么?假设我有一个User包含我的Web应用程序用户的所有信息的类,该类是否应该继承自IdentityUser,我的DbContext是否应该继承?继承自IdentityDbContext?此外,从IdentityDbContext继承dbcontext类的优点是什么?平原D

c# - 无法从 ASP.NET Core 2.0 中的 IdentityUser 和 IdentityRole 继承

我正在尝试完成对.NETCore2.0的更新,但弹出了几个错误:问题:我有两个类,ApplicationRole和ApplicationUser,它们继承了IdentityRole和IdentityUser的一些属性。随着Core2.0的更新,我收到以下错误,声称找不到IdentityRole和IdentityUser。但是,包Microsoft.AspNetCore.Identity.EntityFrameworkCore2.0安装在新版本的.NETCore中关于IdentityRole:消息1:Thetypeornamespacename'IdentityRole'couldnot

c# - 实体类型 IdentityUser 不是当前上下文模型的一部分

我看到与this相同的问题问题,但那里提出的情况似乎并不适用,所以我认为我有一个不同的问题。事实上,我在SO上看到了几个类似的问题,每个问题都有不同的原因和解决方案,所以我认为这个错误必须来自高层。也就是说……我有一个EF代码优先数据库模型,我正在尝试使用IdentityUser来扩展我的MVC5站点的标准注册。我有扩展的UserModel:namespaceMyMvcSite.Models{publicclassUserModel:IdentityUser{publicstringBillingId{get;set;}publicvirtualICollectionDatabases

c# - 在 Web API 中更新身份用户声明

我目前正在尝试将用户的电子邮件/用户名从移动应用程序更新到WebAPI项目。我目前正在使用oauth和token身份验证。更新身份用户时,用户变得未经身份验证,因为用户名和访问token不再有效。根据我所阅读的内容,我必须更新身份声明。到目前为止,这是我尝试过的:varidentity=newClaimsIdentity(User.Identity);if(result){varidentityUser=awaitUserManager.FindByNameAsync(User.Identity.Name);identityUser.Email=AntiXssEncoder.HtmlE

如何使用MVC 5在IdentityUser列表上显示自定义属性?

我正在尝试在用户索引上显示自定义用户属性的内容。我添加了employee_id和name这些已经在数据库中,我保存了用户创建。问题是,在列出用户时,我无法访问这些属性。我有de关注ApplicationUser班级:publicclassApplicationUser:IdentityUser{publicasyncTaskGenerateUserIdentityAsync(UserManagermanager){//NotetheauthenticationTypemustmatchtheonedefinedinCookieAuthenticationOptions.Authenticati

c# - 如何使用 MVC5 和 Entity Framework 使用自定义属性更新 IdentityUser

我正在使用内置身份框架进行用户管理,并想向AspNetUsers表添加一些自定义项。到目前为止,我遇到的每个问题的解决方案都会导致另一个问题。如果我对用户模型进行更改(例如,通过在AspNetUsers表中添加邮政编码属性和匹配字段),然后调用UserManager.UpdateAsync(user),它会成功但不会更新中的邮政编码字段数据库。至少oneotherSOquestion已尝试处理此问题。但是那里建议的修复破坏了其他东西:1)创建另一个UserDbContext实例并尝试附加用户对象导致EntityFramework提示“一个实体对象不能被多个IEntityChangeTr

c# - 如何使用自定义属性扩展 IdentityUser

我正在使用asp.netIdentity2.0供用户登录我的网站,身份验证详细信息存储在SQL数据库中。Asp.netIdentity已以标准方式实现,可在许多在线教程中找到。IdentityModels中的ApplicationUser类已扩展为包含自定义属性:publicclassApplicationUser:IdentityUser{publicasyncTaskGenerateUserIdentityAsync(UserManagermanager,stringauthenticationType){CookieAuthenticationOptions.Authentica

c# - 如何使用 UserManager 在 IdentityUser 上加载导航属性

我已扩展IdentityUser以包含用户地址的导航属性,但是当使用UserManager.FindByEmailAsync获取用户时,导航属性未填充。ASP.NETIdentityCore是否有一些方法来填充导航属性,例如EntityFramework的Include(),还是我必须手动完成?我已经像这样设置了导航属性:publicclassMyUser:IdentityUser{publicint?AddressId{get;set;}[ForeignKey(nameof(AddressId))]publicvirtualAddressAddress{get;set;}}publi