title: Not creating database using Migration command Update-Database in ASP.Net Core 2
body: <p>I created new ASP.Net core project with WebAPI. Using the below link.</p>
  
  <p><a href="https://fullstackmark.com/post/13/jwt-authentication-with-aspnet-core-2-web-api-angular-5-net-core-identity-and-facebook-login" rel="noreferrer">jwt-authentication-with-aspnet-core-2-web-api-angular-5-net-core-identity-and-facebook-login</a></p>
  
  <p>I have to use add-migration update-database manually.</p>
  
  <p>Here I add one thing more that I don't know how to debug app in VS Code. After created my project in VS Code I open my project in Visual Studio 2017.</p>
  
  <p>When I about to run the update command <code>Update-Database</code> in Package Manager Console. I encounter below error also in my understanding the above command is for create the database and add migrations tables in it. (Correct me If I'm wrong). </p>
  
  <pre><code> fail: Microsoft.EntityFrameworkCore.Database.Command[20102]
    Failed executing DbCommand(3ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
    CREATE TABLE[AspNetRoles] (
  
       [Id] nvarchar(450) NOT NULL,
       [ConcurrencyStamp] nvarchar(max) NULL,
        [Name] nvarchar(256) NULL,
        [NormalizedName] nvarchar(256) NULL,
        CONSTRAINT[PK_AspNetRoles] PRIMARY KEY([Id])
    );
   System.Data.SqlClient.SqlException(0x80131904): There is already an object named 'AspNetRoles' in the database.
  
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
  
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action 1 wrapCloseInAction)
  
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
  
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean&amp; dataReady)
  
   at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
  
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite, String methodName)
  
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
  
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary2 parameterValues)
  
   ClientConnectionId:56b94f04-73ff-4391-87fc-36a6c256c650
  
   Error Number:2714,State:6,Class:16
  
   System.Data.SqlClient.SqlException(0x80131904): There is already an object named 'AspNetRoles' in the database.
  
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
  
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
  
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
  
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean&amp; dataReady)
  
   at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
  
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite, String methodName)
  
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
  
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary2 parameterValues)
  
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary2 parameterValues)
  
   at      Microsoft.EntityFrameworkCore.Migrations.MigrationCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary2 parameterValues)
  
  
   at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQuery(IEnumerable1 migrationCommands, IRelationalConnection connection)
  
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
  
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType)
  
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.&lt;&gt;c__DisplayClass0_1.&lt;.ctor&gt;b__0()
  
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
  
   ClientConnectionId:56b94f04-73ff-4391-87fc-36a6c256c650
  
   Error Number:2714, State:6, Class:16
  
   There is already an object named 'AspNetRoles' in the database.`
  </code></pre>
  
  <p>Also I share some of my code here and upload my app on <a href="https://github.com/AhmerAli/ASP.Net-Core-2-webapi-Application" rel="noreferrer">github</a></p>
  
  <p><strong>program.cs</strong></p>
  
  <pre><code>namespace server
  {
      public class Program
      {
          public static void Main(string[] args)
          {
              BuildWebHost(args).Run();
          }
  
          public static IWebHost BuildWebHost(string[] args) =&gt;
               WebHost.CreateDefaultBuilder(args)
              .UseStartup&lt;Startup&gt;()
              .Build();
  
      }
  }
  </code></pre>
  
  <p><strong>Startup.cs</strong></p>
  
  <pre><code>public class Startup
  {
      private const string SecretKey = "iNivDmHLpUA223sqsfhqGbMRdRj1PVkH"; // todo: get this from somewhere secure
      private readonly SymmetricSecurityKey _signingKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(SecretKey));
  
      public Startup(IConfiguration configuration)
      {
          Configuration = configuration;
      }
  
      public IConfiguration Configuration { get; }
  
      // This method gets called by the runtime. Use this method to add services to the container.
      public void ConfigureServices(IServiceCollection services)
      {
          // Add framework services.
          services.AddDbContext&lt;ApplicationDbContext&gt;(options =&gt;
              options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"),
                  b =&gt; b.MigrationsAssembly("server")));
  
          services.AddSingleton&lt;IJwtFactory, JwtFactory&gt;();
  
          // Register the ConfigurationBuilder instance of FacebookAuthSettings
          services.Configure&lt;FacebookAuthSettings&gt;(Configuration.GetSection(nameof(FacebookAuthSettings)));
  
          services.TryAddTransient&lt;IHttpContextAccessor, HttpContextAccessor&gt;();
  
          // jwt wire up
          // Get options from app settings
          var jwtAppSettingOptions = Configuration.GetSection(nameof(JwtIssuerOptions));
  
          // Configure JwtIssuerOptions
          services.Configure&lt;JwtIssuerOptions&gt;(options =&gt;
          {
              options.Issuer = jwtAppSettingOptions[nameof(JwtIssuerOptions.Issuer)];
              options.Audience = jwtAppSettingOptions[nameof(JwtIssuerOptions.Audience)];
              options.SigningCredentials = new SigningCredentials(_signingKey, SecurityAlgorithms.HmacSha256);
          });
  
          var tokenValidationParameters = new TokenValidationParameters
          {
              ValidateIssuer = true,
              ValidIssuer = jwtAppSettingOptions[nameof(JwtIssuerOptions.Issuer)],
  
              ValidateAudience = true,
              ValidAudience = jwtAppSettingOptions[nameof(JwtIssuerOptions.Audience)],
  
              ValidateIssuerSigningKey = true,
              IssuerSigningKey = _signingKey,
  
              RequireExpirationTime = false,
              ValidateLifetime = true,
              ClockSkew = TimeSpan.Zero
          };
  
          services.AddAuthentication(options =&gt;
          {
              options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
              options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
  
          }).AddJwtBearer(configureOptions =&gt;
          {
              configureOptions.ClaimsIssuer = jwtAppSettingOptions[nameof(JwtIssuerOptions.Issuer)];
              configureOptions.TokenValidationParameters = tokenValidationParameters;
              configureOptions.SaveToken = true;
          });
  
          // api user claim policy
          services.AddAuthorization(options =&gt;
          {
              options.AddPolicy("ApiUser", policy =&gt; policy.RequireClaim(Constants.Strings.JwtClaimIdentifiers.Rol, Constants.Strings.JwtClaims.ApiAccess));
          });
  
          // add identity
          var builder = services.AddIdentityCore&lt;EmployeeProfile&gt;(o =&gt;
          {
              // configure identity options
              o.Password.RequireDigit = false;
              o.Password.RequireLowercase = false;
              o.Password.RequireUppercase = false;
              o.Password.RequireNonAlphanumeric = false;
              o.Password.RequiredLength = 6;
          });
          builder = new IdentityBuilder(builder.UserType, typeof(IdentityRole), builder.Services);
          builder.AddEntityFrameworkStores&lt;ApplicationDbContext&gt;().AddDefaultTokenProviders();
  
          services.AddAutoMapper();
          services.AddMvc().AddFluentValidation(fv =&gt; fv.RegisterValidatorsFromAssemblyContaining&lt;Startup&gt;());
      }
  
      // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
      public void Configure(IApplicationBuilder app, IHostingEnvironment env)
      {
          if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
          }
  
          app.UseExceptionHandler(
              builder =&gt;
              {
                  builder.Run(
                      async context =&gt;
                          {
                              context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                              context.Response.Headers.Add("Access-Control-Allow-Origin", "*");
  
                              var error = context.Features.Get&lt;IExceptionHandlerFeature&gt;();
                              if (error != null)
                              {
                                  context.Response.AddApplicationError(error.Error.Message);
                                  await context.Response.WriteAsync(error.Error.Message).ConfigureAwait(false);
                              }
                          });
              });
  
          app.UseAuthentication();
          app.UseDefaultFiles();
          app.UseStaticFiles();
          app.UseMvc();
      }
  }
  </code></pre>
  
  <p><strong>ApplicationDbContext.cs</strong></p>
  
  <pre><code>public class ApplicationDbContext : IdentityDbContext&lt;EmployeeProfile&gt;
  {
      public ApplicationDbContext(DbContextOptions options)
          : base(options)
      {
      }
  
      public DbSet&lt;EmployeeProfile&gt; EmployeeProfiles { get; set; }
  }
  </code></pre>
  
  <p>My Question is how I create my database using migration update command and what's going wrong in my code.</p>