public void Configure(IApplicationBuilder app, IHostingEnvironment env, RecipeContext recipeContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler(appBuilder => { appBuilder.Run(async context => { context.Response.StatusCode = 500; await context.Response.WriteAsync("Internal error occurred."); }); }); } recipeContext.EnsureSeedDataForContext(); AutoMapper.Mapper.Initialize(cfg => { cfg.CreateMap <IEnumerable <Entities.Category>, Models.CategoryListDto>() .ConvertUsing <CategoryListConverter>(); cfg.CreateMap <IEnumerable <Entities.Recipe>, Models.RecipeListDto>() .ConvertUsing <RecipeListConverter>(); cfg.CreateMap <Entities.Recipe, Models.RecipeDto>() .ForMember(destination => destination.Categories, source => source.MapFrom(recipe => recipe.RecipeCategories)); cfg.CreateMap <Entities.RecipeCategory, String>() .ConvertUsing(source => source.Category.Name); cfg.CreateMap <Entities.Ingredient, Models.IngredientDto>(); cfg.CreateMap <Entities.Amount, Models.AmountDto>(); cfg.CreateMap <Entities.Directions, Models.DirectionsDto>(); cfg.CreateMap <Models.RecipeForCreationDto, Entities.Recipe>(); cfg.CreateMap <Models.IngredientDto, Entities.Ingredient>(); cfg.CreateMap <Models.AmountDto, Entities.Amount>(); cfg.CreateMap <Models.DirectionsDto, Entities.Directions>(); }); app.UseMvc(); }