public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddDbContext <ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddDbContext <PKShopContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddDbContext <EventStoreContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddIdentity <ApplicationUser, IdentityRole>() .AddEntityFrameworkStores <ApplicationDbContext>() .AddDefaultTokenProviders(); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(o => { o.LoginPath = new PathString("/login"); o.AccessDeniedPath = new PathString("/home/access-denied"); }) .AddFacebook(o => { o.AppId = Configuration["Authentication:Facebook:AppId"]; o.AppSecret = Configuration["Authentication:Facebook:AppSecret"]; }) .AddGoogle(googleOptions => { googleOptions.ClientId = Configuration["Authentication:Google:ClientId"]; googleOptions.ClientSecret = Configuration["Authentication:Google:ClientSecret"]; }); services.AddMvc(); services.AddScoped <ServiceFactory>(x => x.GetService); services.AddMediatR(typeof(Startup)); services.AddAutoMapperSetup(); var builder = new ContainerBuilder(); builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly()) .AsImplementedInterfaces(); DomainContainer.Load(builder); BusContainer.Load(builder); IndentityContainer.Load(builder); ServicesContainer.Load(builder); DataContainer.Load(builder); builder.Populate(services); Container = builder.Build(); return(new AutofacServiceProvider(Container)); }