title: DbUpdateException error trying to use EF core code first
body: <p>I have a simple Web API and I am trying to use entity framework core code first, with an external sql server database hosted on AWS RDS. My aim is for EF to create my model database/tables automatically, based on my context and models,  the first time I use Swagger to create an object. Although when I try to post an object to my API with Swagger, tables do not get created and instead I get the following error: <code>Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details.
   ---&gt; Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid object name 'Users'.</code> </p>
  
  <p>Did I set up EF incorrectly?</p>
  
  <p>Db Context:</p>
  
  <pre><code>namespace FitnessTrackerAPI.Data
  {
      public class FitnessTrackerAPIContext : DbContext
      {
          public FitnessTrackerAPIContext (DbContextOptions&lt;FitnessTrackerAPIContext&gt; options)
              : base(options)
          {
          }
  
          public DbSet&lt;FitnessTracker.UserData&gt; Users { get; set; }
  
          public DbSet&lt;FitnessTracker.WorkoutData&gt; Workouts { get; set; }
      }
  }
  </code></pre>
  
  <p>I also added the following to Startup.cs:</p>
  
  <pre><code>    public void ConfigureServices(IServiceCollection services)
      {
           services.AddDbContext&lt;FitnessTrackerAPIContext&gt;(options =&gt;
           options.UseSqlServer(Configuration.GetConnectionString("FitnessTrackerAPIContext")));
           ....
  
      private void InitializeDatabase(IApplicationBuilder app)
      {
           using (var serviceScope = app.ApplicationServices.GetService&lt;IServiceScopeFactory&gt;().CreateScope())
           {
                  var context = serviceScope.ServiceProvider.GetRequiredService&lt;FitnessTrackerAPIContext&gt;();
                  context.Database.Migrate();
           }
      }
  
      // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
      public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
      {
          //Apply pending migrations
          InitializeDatabase(app);
          ....
  </code></pre>
  
  <p>Connection String in appsettings.json: <code>"ConnectionStrings": {
      "FitnessTrackerAPIContext": "Server=fitnessapi.clxnbxbuoxx1.eu-west-1.rds.amazonaws.com,1433;User ID=XXXXX;Password=XXXXX; Initial Catalog=fitnessapi; Database=fitnessapi; Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"</code></p>