// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, TodoAngularDbContext todoAngularDbContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMvc(); app.UseStaticFiles(); AutoMapper.Mapper.Initialize(cfg => { cfg.CreateMap <TodoForCreationDto, Todo>(); cfg.CreateMap <Todo, TodoDto>(); cfg.CreateMap <TodoForUpdateDto, Todo>(); }); todoAngularDbContext.EnsureSeedDataForContext(); }
public static void EnsureSeedDataForContext(this TodoAngularDbContext ctx) { ctx.Todos.RemoveRange(ctx.Todos); ctx.SaveChanges(); Todo[] todos = { new Todo { Title = "Test todo 1", Completed = false }, new Todo { Title = "Test todo 2", Completed = false }, new Todo { Title = "Test todo 3", Completed = false } }; ctx.AddRange(todos); ctx.SaveChanges(); }