diff --git a/src/Web/Startup.cs b/src/Web/Startup.cs index e6ee913..c3bd22c 100644 --- a/src/Web/Startup.cs +++ b/src/Web/Startup.cs @@ -35,37 +35,28 @@ namespace Microsoft.eShopWeb.Web // use real database // ConfigureProductionServices(services); - - ConfigureServices(services); } private void ConfigureInMemoryDatabases(IServiceCollection services) { // use in-memory database - services.AddDbContext(c => + services.AddDbContext(c => c.UseInMemoryDatabase("Catalog")); // Add Identity DbContext services.AddDbContext(options => options.UseInMemoryDatabase("Identity")); + + ConfigureServices(services); } public void ConfigureProductionServices(IServiceCollection services) { // use real database + // Requires LocalDB which can be installed with SQL Server Express 2016 + // https://www.microsoft.com/en-us/download/details.aspx?id=54284 services.AddDbContext(c => - { - try - { - // Requires LocalDB which can be installed with SQL Server Express 2016 - // https://www.microsoft.com/en-us/download/details.aspx?id=54284 - c.UseSqlServer(Configuration.GetConnectionString("CatalogConnection")); - } - catch (Exception ex) - { - //TODO: log the exception details - } - }); + c.UseSqlServer(Configuration.GetConnectionString("CatalogConnection"))); // Add Identity DbContext services.AddDbContext(options => @@ -117,7 +108,7 @@ namespace Microsoft.eShopWeb.Web } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, + public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) diff --git a/src/Web/appsettings.json b/src/Web/appsettings.json index 3c0e6c2..20d2185 100644 --- a/src/Web/appsettings.json +++ b/src/Web/appsettings.json @@ -1,7 +1,7 @@ { "ConnectionStrings": { - "CatalogConnection": "Server=(localdb)\\v11.0;Integrated Security=true;Initial Catalog=Microsoft.eShopOnWeb.CatalogDb;", - "IdentityConnection": "Server=(localdb)\\v11.0;Integrated Security=true;Initial Catalog=Microsoft.eShopOnWeb.Identity;" + "CatalogConnection": "Server=(localdb)\\mssqllocaldb;Integrated Security=true;Initial Catalog=Microsoft.eShopOnWeb.CatalogDb;", + "IdentityConnection": "Server=(localdb)\\mssqllocaldb;Integrated Security=true;Initial Catalog=Microsoft.eShopOnWeb.Identity;" }, "CatalogBaseUrl": "", "Logging": {