// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var connectionString = _appConfiguration.ConnectionStrings.Database .Replace("{DataDirectory}", Path.Combine(_workingDirectory, "Data")); services.AddSingleton(_appConfiguration); services.AddSingleton(Logger.CreateInstance()); services.AddDbContext <ProductsServiceDbContext>(b => b.UseSqlServer(connectionString)); services.AddScoped <IProductRepository, ProductRepository>(); services.AddScoped <IProductOptionRepository, ProductOptionRepository>(); services.AddScoped <IProductService, ProductService>(); services.AddScoped <IProductOptionService, ProductOptionService>(); EntitiesMapper.Initialize(); services.AddMvc(); services.AddMvcCore().AddApiExplorer(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); }