title: "How to fix" SqlException: Invalid object name 'Orders'. databatase location?
body: <p>I followed the instructions in this video <a href="https://docs.microsoft.com/en-us/visualstudio/get-started/csharp/tutorial-aspnet-core-ef-step-03?view=vs-2019" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/visualstudio/get-started/csharp/tutorial-aspnet-core-ef-step-03?view=vs-2019</a>  to try to add a products database. and after some (inital bugginess I first crashed and the website asked me to apply migrations and i hit apply) an then it eventually worked.</p>
  
  <p>The instructions tell you to create a new models folder and then add a class to it. then in the pages fold add a new folder for your model followed by a new scaffolded item (razer page with entity fw (crud)). I then added the following code to make sure the database gets created  in my program.cs to make sure the database is created </p>
  
  <pre><code>  var host = CreateWebHostBuilder(args).Build();
  
              using (var scope = host.Services.CreateScope())
              {
                  var services = scope.ServiceProvider;
  
                  try
                  {
                      var context = services.GetRequiredService&lt;EisenMNdbContext&gt;();
                      context.Database.EnsureCreated();
                  }
                  catch (Exception ex)
                  {
                      var logger = services.GetRequiredService&lt;ILogger&lt;Program&gt;&gt;();
                      logger.LogError(ex, "An error occurred creating the DB.");
                  }
              }
  
              host.Run();
  
  </code></pre>
  
  <p>I that and it  worked for products.
  I then wanted to add a second model/app called orders so I added a nother class to models, and then created another folder and added a scaffolded item doing the same process but this time i get this:</p>
  
  <p>SqlException: Invalid object name 'Order'.</p>
  
  <p>System.Data.SqlClient.SqlCommand+&lt;>c.b__122_0(Task result)</p>
  
  <p>I noticed in links like this one </p>
  
  <p><a href="https://stackoverflow.com/questions/5374482/sqlexception-0x80131904-invalid-object-name-dbo-categories">SqlException (0x80131904): Invalid object name &#39;dbo.Categories&#39;</a></p>
  
  <p>that people often had the database table as the wrong name. is there a place where I can edit that?<a href="https://i.stack.imgur.com/xhrFG.png" rel="nofollow noreferrer">list of file directories</a></p>
  
  <p>here is some more of the error log if that helps: </p>
  
  <pre><code>qlException: Invalid object name 'Orders'.
  
      System.Data.SqlClient.SqlCommand+&lt;&gt;c.&lt;ExecuteDbDataReaderAsync&gt;b__122_0(Task&lt;SqlDataReader&gt; result)
      System.Threading.Tasks.ContinuationResultTaskFromResultTask&lt;TAntecedentResult, TResult&gt;.InnerInvoke()
      System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, object state)
      System.Threading.Tasks.Task.ExecuteWithThreadLocal(ref Task currentTaskSlot)
      Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteAsync(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary&lt;string, object&gt; parameterValues, CancellationToken cancellationToken)
  
  </code></pre>
  
  <p>my db context looks like this if that matters</p>
  
  <pre><code>    {
          public EisenMNdbContext (DbContextOptions&lt;EisenMNdbContext&gt; options)
              : base(options)
          {
          }
  
          public DbSet&lt;EisenMN.Models.Product&gt; Products { get; set; }
  
          public DbSet&lt;EisenMN.Models.Order&gt; Orders { get; set; }
  
  
      }
  }
  </code></pre>