title: Entity Framework - Empty Lists
body: <p>Helloes,</p>
  
  <p>I'm using Identity Server 4 and I'm having some issues with Entity Framework.</p>
  
  <p>I'm trying to make a custom CRUD for Clients. 
  When trying to get a single client information, I'm trying to get several Lists using Entity Framework (default IS4 implementation) but these Lists are returned empty for some reason...</p>
  
  <p><a href="https://github.com/IdentityServer/IdentityServer4.Samples" rel="nofollow noreferrer">here</a> you can use the Quickstart 8 - 8_EntityFrameworkStorage - and try to access a Client to get his properties.</p>
  
  <p>Here is my current code</p>
  
  <p>Db Context</p>
  
  <pre><code>namespace IdentityServer4.EntityFramework.DbContexts
  {
      public class ConfigurationDbContext : DbContext, IConfigurationDbContext, IDisposable
      {
          public ConfigurationDbContext(DbContextOptions&lt;ConfigurationDbContext&gt; options, ConfigurationStoreOptions storeOptions);
  
          public DbSet&lt;Client&gt; Clients { get; set; }
          public DbSet&lt;IdentityResource&gt; IdentityResources { get; set; }
          public DbSet&lt;ApiResource&gt; ApiResources { get; set; }
  
          public Task&lt;int&gt; SaveChangesAsync();
          protected override void OnModelCreating(ModelBuilder modelBuilder);
      }
  }
  </code></pre>
  
  <p>Client Entity</p>
  
  <pre><code>namespace IdentityServer4.EntityFramework.Entities
  {
      public class Client
      {
          public Client();
  
          public bool AllowOfflineAccess { get; set; }
          public List&lt;ClientScope&gt; AllowedScopes { get; set; }
          // ...
      }
  }
  </code></pre>
  
  <p>Custom Service, where I am trying to get the </p>
  
  <pre><code>clnt.AllowedScopes
  </code></pre>
  
  <p>but is empty...</p>
  
  <pre><code>namespace IdentityServer.Services
  {
      public class ClientService
      {
          private readonly ConfigurationDbContext _context;
          private readonly ILogger _logger;
  
          public ClientService(ILoggerFactory loggerFactory, ConfigurationDbContext context)
          {
              _logger = loggerFactory.CreateLogger&lt;ClientService&gt;();
              _context = context;
          }
  
          //...
          public ClientViewModel GetClientViewModel(int clientId)
          {
              var clnt = _context.Clients.FirstOrDefault(i =&gt; i.Id == clientId);
              //todo :: return also the lists (they are coming empty)
  
              var vm = new ClientViewModel();
  
              if (clnt == null) return vm;
  
              vm = new ClientViewModel()
              {
                  Id = clnt.Id,
                  ClientName = clnt.ClientName,
                  ClientId = clnt.ClientId,
                  AllowedGrantTypes = clnt.AllowedGrantTypes,
                  ClientSecrets = clnt.ClientSecrets,
                  RedirectUris = clnt.RedirectUris,
                  PostLogoutRedirectUris = clnt.PostLogoutRedirectUris,
                  AllowedScopes = clnt.AllowedScopes,
                  AllowAccessTokensViaBrowser = clnt.AllowAccessTokensViaBrowser,
                  AllowOfflineAccess = clnt.AllowOfflineAccess,
                  AlwaysIncludeUserClaimsInIdToken = clnt.AlwaysIncludeUserClaimsInIdToken,
                  AlwaysSendClientClaims = clnt.AlwaysSendClientClaims,
                  PrefixClientClaims = clnt.PrefixClientClaims,
                  RequireConsent = clnt.RequireConsent
              };
              return vm;
          }
  
          //...
      }
  }
  </code></pre>
  
  <p>I'm getting the correct Client, it has Scopes (I can check it on the database and use it for the IS authentication flow) but the List is empty...</p>
  
  <p>Any thoughts on this?</p>
  
  <p>Cheers</p>