Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ardalis committed Jun 7, 2018
2 parents 48ad346 + faa41f9 commit a94990e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
23 changes: 7 additions & 16 deletions src/Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,37 +35,28 @@ public void ConfigureDevelopmentServices(IServiceCollection services)

// use real database
// ConfigureProductionServices(services);

ConfigureServices(services);
}

private void ConfigureInMemoryDatabases(IServiceCollection services)
{
// use in-memory database
services.AddDbContext<CatalogContext>(c =>
services.AddDbContext<CatalogContext>(c =>
c.UseInMemoryDatabase("Catalog"));

// Add Identity DbContext
services.AddDbContext<AppIdentityDbContext>(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<CatalogContext>(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<AppIdentityDbContext>(options =>
Expand Down Expand Up @@ -117,7 +108,7 @@ public void ConfigureServices(IServiceCollection services)
}

// 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())
Expand Down
4 changes: 2 additions & 2 deletions src/Web/appsettings.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit a94990e

Please sign in to comment.