2017-02-21 4 views
0

У меня есть ошибка в следующем коде в общественных недействительных ConfigureServices (услуги) IServiceCollectionкак добавлять пользовательские TUser и TRole в services.AddIdentity Asp Ядра

services.AddIdentity<ApsUser, ApsRole>(option => 
     { 
      option.Password.RequiredLength = 6; 
     }) 

GenericArguments [0], «project.Core.Users .ApsUser ',' Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore`9 [TUser, TRole, TContext, TKey, TUserClaim, TUserRole, TUserLogin, TUserToken, TRoleClaim] 'нарушает ограничение параметра типа «TUser».

мой класс

public class ApsUser : IdentityUser<int, UserClaim, UserRole, UserLogin>, IEntity 
{ 
    public UserState State { get; set; } 

    #region IEntityLogFields 



    #endregion 

} 

    public class UserRole : IdentityUserRole<int>, IEntity<int> 
{ 
    public int Id { get; set; } 

    #region IEntityLogFields 



    #endregion 

} 

Как исправить?

+0

Не могли бы вы показать реализации ApsRole и ApsUser? – Win

+0

Я отредактировал первое сообщение – AndreyShiryaev

+0

В чем причина 'ApsUser' наследования от' IdentityUser , IEntity'? «ApsUser: IdentityUser» недостаточно? – Win

ответ

0

Temporary я сделал это

  1. пользователя и роль

    public class ApsUser : IdentityUser<int>, IEntity

    общественного класса ApsRole: IdentityRole, IEntityLog

  2. startup.cs

    services.AddIdentity (option => { опция.Password.RequiredLength = 6; option.Password.RequireLowercase = false; option.Password.RequireNonAlphanumeric = false; option.Password.RequireUppercase = false; option.Password.RequireNonAlphanumeric = false;

    }) 
         .AddEntityFrameworkStores<ApContext, int>() 
         .AddDefaultTokenProviders();