title: EF Core Data is Null
body: <p>Most of the answers on this state that the DbSet on the context must be a property. However that does not seem to be the case in this instance since the DbSet of this context is a property. Here is the sample code that I can use to recreate the problem. Please advise.</p>
  
  <h2>Here is the code:</h2>
  
  <p>DbContext</p>
  
  <pre><code>using Microsoft.EntityFrameworkCore;
  using System.Collections.Generic;
  using System.Linq;
  using System.Threading.Tasks;
  
  namespace Dal
  {
      public class SampleContext : DbContext
      {
          public DbSet&lt;Model.ItemCode&gt; ItemCodes { get; set; }
  
          public SampleContext(DbContextOptions&lt;SampleContext&gt; options) : base(options)
          {
          }
  
          protected override void OnModelCreating(ModelBuilder modelBuilder)
          {
              modelBuilder.ApplyConfiguration(new Mapping.ItemCodeConfiguration());
              base.OnModelCreating(modelBuilder);
          }
  
          public async Task&lt;IEnumerable&lt;Model.ItemCode&gt;&gt; GetCodesByGroup(int group)
          {
              return await ItemCodes.Where(g =&gt; g.GroupId == group).ToListAsync();
          }
  
      }
  }
  </code></pre>
  
  <p>Model</p>
  
  <pre><code>namespace Dal.Model
  {
      public class ItemCode
      {
          public int Id { get; set; }
          public string Code { get; set; }
          public string Description { get; set; }
          public int Quantity { get; set; }
          public int KcId { get; set; }
          public int CategoryId { get; set; }
          public int GroupId { get; set; }
      }
  }
  </code></pre>
  
  <p>Data Mapping</p>
  
  <pre><code>using Microsoft.EntityFrameworkCore;
  using Microsoft.EntityFrameworkCore.Metadata.Builders;
  
  namespace Dal.Mapping
  {
      public class ItemCodeConfiguration : IEntityTypeConfiguration&lt;Model.ItemCode&gt;
      {
          public void Configure(EntityTypeBuilder&lt;Model.ItemCode&gt; builder)
          {
              builder.HasKey(b =&gt; b.Id);
              builder.Property(b =&gt; b.Description)
                  .HasColumnName("Description")
                  .HasColumnType("nvarchar(255)")
                  .IsRequired();
              builder.Property(b =&gt; b.Code)
                  .HasColumnName("Code")
                  .IsRequired();
              builder.Property(b =&gt; b.KcId)
                  .HasColumnName("KcId");
              builder.Property(b =&gt; b.Quantity)
                  .HasColumnName("Quantity");
              builder.Property(b =&gt; b.GroupId)
                  .HasColumnName("GroupId")
                  .IsRequired();
              builder.Property(b =&gt; b.CategoryId)
                  .HasColumnName("CategoryId")
                  .IsRequired();
              builder.ToTable("ItemCode", "lookup");
          }
      }
  }
  </code></pre>
  
  <p>Test Class</p>
  
  <pre><code>using Microsoft.EntityFrameworkCore;
  using Xunit;
  
  namespace Dal.Test
  {
      public class DataTest
      {
          readonly SampleContext context;
          public DataTest()
          {
              var testContextOptions = new DbContextOptionsBuilder&lt;SampleContext&gt;();
              testContextOptions.UseSqlServer(@"Server=localServerName;Database=SampleAppDb;User Id=SampleUser;Password=sampleUser!Password");
              testContextOptions.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
              context = new SampleContext(testContextOptions.Options);
          }
  
  
          [Fact]
          public async void Test1()
          {
              var codes = await context.GetCodesByGroup(1);
              Assert.NotNull(codes);
              Assert.NotEmpty(codes);
          }
      }
  }
  </code></pre>