Я пытаюсь получить свой репозиторий пользователей следующим образом:
var userRepository = context.RequestServices.GetService<Repository<User>>();
Но моя проблема в том, что он разрешается нулем, я определил его так:
services.AddScoped(typeof(UserRepository), typeof(UserRepository));
И вот как выглядит класс / интерфейс репозитория:
public interface IRepository<T> where T : class, IAppEntity
{
//Code
}
public abstract class Repository<T> : IRepository<T> where T : class, IAppEntity
{
//Code
}
А это UserRepository:
public class UserRepository : Repository<User>
{
public UserRepository(ApplicationDbContext context) : base(context)
{
}
}
И наконец Модель пользователя:
public class User : IdentityUser, IAppEntity
{
//Code
}