title: .NET CORE 2.0 Unable to resolve service for type while attempting to activate
body: <p>I have a IDataRepository.cs file that contains an interface and its implementation like so:</p>
  
  <pre><code>public interface IDataRepository&lt;TEntity, U&gt; where TEntity : class
  {
      IEnumerable&lt;TEntity&gt; GetAll();
      TEntity Get(U id);
      TEntity GetByString(string stringValue);
      long Add(TEntity b);
      long Update(U id, TEntity b);
      long Delete(U id);
  }
  </code></pre>
  
  <p>I have another class TokenManager.cs that implements IDataRepository Interface:</p>
  
  <pre><code>public class TokenManager : IDataRepository&lt;Token, long&gt;
  {
      ApplicationContext ctx;
      public TokenManager(ApplicationContext c)
      {
          ctx = c;
      }
  
      //Get the Token Information by ID
      public Token Get(long id)
      {
          var token = ctx.Token.FirstOrDefault(b =&gt; b.TokenId == id);
          return token;
      }
  
      public IEnumerable&lt;Token&gt; GetAll()
      {
          var token = ctx.Token.ToList();
          return token;
      }
  
  
      //Get the Token Information by ID
      public Token GetByString(string clientType)
      {
          var token = ctx.Token.FirstOrDefault(b =&gt; b.TokenClientType == clientType);
          return token;
      }
  
      public long Add(Token token)
      {
          ctx.Token.Add(token);
          long tokenID = ctx.SaveChanges();
          return tokenID;
      }
  
  }
  </code></pre>
  
  <p>and finally, I have a controller to put all things together, my controller files looks like this:</p>
  
  <pre><code>[Route("api/[controller]")]
  public class TokenController : Controller
  {
      private IDataRepository&lt;Token, long&gt; _iRepo;
      public TokenController(IDataRepository&lt;Token, long&gt; repo)
      {
          _iRepo = repo;
      }
  
      // GET: api/values  
      [HttpGet]
      public IEnumerable&lt;Token&gt; Get()
      {
          return _iRepo.GetAll();
      }
  
      // GET api/values/produccion
      [HttpGet("{stringValue}")]
      public Token Get(string stringValue)
      {
          return _iRepo.GetByString(stringValue);
      }
  }
  </code></pre>
  
  <p>But the problem is that every time I try to access some method from my API, for example using postman I get the error:</p>
  
  <blockquote>
    <p>InvalidOperationException: Unable to resolve service for type FECR_API.Models.Repository.IDataRepository`2[FECR_API.Models.Token,System.Int64] while attempting to activate;FECR_API.Controllers.TokenController</p>
  </blockquote>
  
  <p>I tried using something like this inside ConfigureServices, but get a conversion error</p>
  
  <pre><code>services.AddScoped&lt;IDataRepository, TokenManager&gt;();
  </code></pre>
  
  <p>Any idea what I'm doing wrong?</p>