public EmployeesController(ApiProjectContext context) { _context = context; //if (_context.TodoItems.Count() == 0) //{ // // Create a new TodoItem if collection is empty, // // which means you can't delete all TodoItems. // _context.TodoItems.Add(new TodoItem { Name = "Item1" }); // _context.SaveChanges(); //} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApiProjectContext context) { //If Database not exist then create database context.Database.EnsureCreated(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseCors(builder => builder.WithOrigins("http://localhost:3000").AllowAnyHeader().AllowAnyMethod()); app.UseHttpsRedirection(); app.UseMvc(); }