title: Why is repository null
body: <p>I'm making an API and I'm making API calls.<br/>
  I created an repository named <code>IPartnerRepository</code><br/>
  When I run my call It gives the nullexception error.<br/>
  When I debug my code I see that <code>IPartnerRepository</code> is null.<br/>
  My visual studio doesn't show any errors or mistypings.<br/>
  Why can't my program find that repository then? Why is it null?<br/></p>
  
  <p>This is my code:</p>
  
  <pre><code>public IPartnerRepository PartnerRepository { get; set; } // = null
  
  [RequiresAnyRole(Roles.superadmin, Roles.admin)]
  public async Task&lt;PartnerListResponse&gt; Get(PartnerListRequest request)
  {
     var items = await PartnerRepository.GetAllAsync();
     return new PartnerListResponse
     {
        Items = items
     };
  }
  </code></pre>
  
  <p><strong>IPartnerRepository</strong></p>
  
  <pre><code>using System;
  using DTO = Ringdesk.Api.ServiceModel.DTO;
  
  namespace Ringdesk.Api.ServiceModel.Interfaces
  {
     public interface IPartnerRepository : IDtoRepository&lt;DTO.Partner, 
        DTO.PartnerForInsert, DTO.PartnerForUpdate&gt;
     {
     }
  }
  </code></pre>
  
  <p><strong>Partner.cs</strong></p>
  
  <pre><code>using ServiceStack.Model;
  using Ringdesk.Api.ServiceModel.Attributes;
  
  namespace Ringdesk.Api.ServiceModel.DTO
  {
      public class Partner : IHasId&lt;int&gt;
      {
          public int Id { get; set; }
          public string Guid { get; set; }
          [PropertyValue("name")]
          public string Name { get; set; }
      }
  
      public class PartnerForUpdate : IHasId&lt;int&gt;
      {
          public int Id { get; set; }
          public string Name { get; set; }
      }
  
      public class PartnerForInsert
      {
          public string Name { get; set; }    
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/FhuCn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FhuCn.png" alt="the working code with customers"></a></p>
  
  <p><a href="https://i.stack.imgur.com/a29wd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a29wd.png" alt="the partners code that goes wrong"></a></p>
  
  <p><strong>Startup.cs</strong></p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Threading.Tasks;
  using Microsoft.AspNetCore.Builder;
  using Microsoft.AspNetCore.Hosting;
  using Microsoft.Extensions.Configuration;
  using Microsoft.Extensions.DependencyInjection;
  using Microsoft.Extensions.Logging;
  using ServiceStack;
  using Ringdesk.Api.Web.Jobs;
  using NLog.Extensions.Logging;
  using NLog.Web;
  
  namespace Ringdesk.Api.Web
  {
      public class Startup
      {
          public Startup(IConfiguration configuration)
          {
              Configuration = configuration;
          }
  
          public IConfiguration Configuration { get; }
  
          public void ConfigureServices(IServiceCollection services)
          {
              services.AddOrchardCms();
              //services.AddMvc();
          }
  
          public class StartupSettings
          {
              public bool RunJobs { get; set; }
          }
  
          public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IApplicationLifetime lifetime)
          {
              var startupSettings = Configuration.GetSection("startupSettings").Get&lt;StartupSettings&gt;();
  
              if (startupSettings == null || startupSettings.RunJobs)
              {
                  var quartz = new QuartzSetup();
                  lifetime.ApplicationStarted.Register(quartz.Start);
                  lifetime.ApplicationStopping.Register(quartz.Stop);
              }
  
              loggerFactory.AddConsole(Configuration.GetSection("Logging"));
              loggerFactory.AddNLog();
              env.ConfigureNLog("nlog.config");
              loggerFactory.AddDebug();
  
              if (env.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
              }
              else
              {
                  app.UseExceptionHandler("/Home/Error");
              }
  
              app.UseStaticFiles();
              var appSettings = new NetCoreAppSettings(Configuration);
              app.UseServiceStack(new AppHost(appSettings));
              app.UseOrchardCore();
  
              //app.UseMvc(routes =&gt;
              //      {
              //        routes.MapRoute(
              //            name: "default",
              //            template: "{controller=Home}/{action=Index}/{id?}");
              //      });
          }
      }
  }
  </code></pre>