[英]UserManager.GetRoles doesn't work after extending the IdentityUserRole in MVC 5 Dot Net Identity
我通過添加外鍵列擴展了IdentityUserRole,但現在我無法授權或檢索角色信息。 請任何人幫助我解決此問題。
我的IdentityUserRole在AspNetApplications表中有一個外鍵列,並且IdentityUserRole擴展如下
public class AspNetUserRoles : IdentityUserRole
{
[Key]
public string ApplicationId { get; set; }
[ForeignKey("ApplicationId")]
public AspNetApplications AspNetApplications { get; set; }
}
添加遷移后,我可以看到在AspNetUserRoles表中創建了外鍵列。 該表的屏幕截圖如下
在這里我有兩個問題要問
“鑒別符”列與“按層次結構表(TPH)”有關。請參考此鏈接。ASP.NET 遷移中的“鑒別符”列是什么?
關於身份驗證您的區分符列應該有問題。例如,這段代碼UserManager.GetRoles()具有Discriminator的where子句,用於獲取數據。
SELECT [Extent1].[Id] AS [Id], [Extent1].[Name] AS [Name] FROM [dbo].[Roles] AS [Extent1]
WHERE [Extent1].[Discriminator] = N'Role'
我認為發送到數據庫的select命令中的where子句值與數據庫中的值不同
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.