title: How to Read Record From Database in ASP.MVC Core using Entity Framework Core 1.0
body: <p>I am working on simple MVC 6 app with .NET Core 1.0 and trying to read data from database using Entity Framework Core 1.0 and getting following error in my LINQ query from where I am trying to read table; The LINQ query is in HomeController class</p>
  
  <h2>Error</h2>
  
  <pre><code>An unhandled exception occurred while processing the request.
  SqlException: Invalid object name 'TestModel'.
  </code></pre>
  
  <h2>Model Class</h2>
  
  <pre><code>[Table("TestTable")]
  public class TestModel
  {
      [Key]
      public int ID { get; set; }
      public string Name { get; set; }
  }
  </code></pre>
  
  <h2>TestDbContext</h2>
  
  <pre><code>public class TestDbContext: DbContext
  {
      public TestDbContext(DbContextOptions&lt;TestDbContext&gt; options): base(options)
      { }
  
      public DbSet&lt;TestModel&gt; TestModels { get; set; }
  
      protected override void OnModelCreating(ModelBuilder modelBuilder)
      {
          modelBuilder.Entity&lt;TestModel&gt;().ToTable("TestModel");
      }
  }
  </code></pre>
  
  <h2>Startup.cs</h2>
  
  <pre><code>   public void ConfigureServices(IServiceCollection services)
      {
          // Add framework services.
          services.AddApplicationInsightsTelemetry(Configuration);
  
  
          services.AddDbContext&lt;TestDbContext&gt;(options =&gt;
                  options.UseSqlServer(Configuration.GetConnectionString("UCASAppDatabase")));
  
  
          services.AddMvc();
      }
  </code></pre>
  
  <h2>project.json</h2>
  
  <pre><code>"Microsoft.EntityFrameworkCore.SqlServer": "1.0.1",
  "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
  "System.ComponentModel.Annotations": "4.1.0"
  </code></pre>
  
  <h2>appsettings.json</h2>
  
  <pre><code>{
  "ApplicationInsights": {
  "InstrumentationKey": ""
  },
  "Logging": {
   "IncludeScopes": false,
   "LogLevel": {
    "Default": "Debug",
    "System": "Information",
    "Microsoft": "Information"
   }
   },
   "ConnectionStrings": {
    "UCASAppDatabase": "Data Source=mydb;Initial Catalog=UCAS-DB;Integrated Security=True;Persist Security Info=True"
   }
  }
  </code></pre>
  
  <h2>HomeController (trying to read table here!)</h2>
  
  <pre><code> public class HomeController : Controller
  {
      private readonly TestDbContext _context;
      public HomeController(TestDbContext context)
      {
          this._context = context;
      }
  
    public IActionResult About()
      {
              var query = (from b in _context.TestModels
                           select b).ToList();
  
              ViewData["Message"] = "Your application description page.";
  
          return View();
      }
  </code></pre>
  
  <p>Not sure what I missing here!</p>