static DependencyInjectionResolver() { var service = new ServiceCollection(); service.AddTransient <HomeController>(); service.AddTransient <CountryController>(); service.AddTransient <CountyController>(); service.AddTransient <CvController>(); service.AddTransient <ICountryBLL, CountryBLL>(); service.AddTransient <ICountyBLL, CountyBLL>(); service.AddTransient <ICvBLL, CvBLL>(); service.AddTransient <ICountryDAL, CountryDAL>(); service.AddTransient <ICountyDAL, CountyDAL>(); service.AddTransient <ICvDAL, CvDAL>(); service.AddTransient <UserInfo, UserInfo>(s => new UserInfo(HttpContext.Current)); service.AddScoped <LogAdapter, LogAdapter>(); service.AddScoped <DemoDbContext>(s => DemoDbContext.Create()); //service.AddTransient<DemoDbContext>(s => DemoDbContext.Create()); _provider = service.BuildServiceProvider(); }