From 067b2d68a98cca5b709f64a2a70be64f9b1a0a84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Will=20=E4=BF=9D=E5=93=A5?= Date: Tue, 14 Nov 2017 02:41:20 +0800 Subject: [PATCH] Update README.md (#69) Updating "Configuring the sample to use SQL Server" section to reflect to the current sample code. --- README.md | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 51f0c9c..ff7f093 100644 --- a/README.md +++ b/README.md @@ -31,39 +31,20 @@ If you wish to use the sample with a persistent database, you will need to run i ### Configuring the sample to use SQL Server -1. Update `Startup.cs`'s `ConfigureServices` method as follows: +1. Update `Startup.cs`'s `ConfigureDevelopmentServices` method as follows: ``` -public void ConfigureServices(IServiceCollection services) -{ - // 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 + public void ConfigureDevelopmentServices(IServiceCollection services) { - //c.UseInMemoryDatabase("Catalog"); - c.UseSqlServer(Configuration.GetConnectionString("CatalogConnection")); - c.ConfigureWarnings(wb => - { - //By default, in this application, we don't want to have client evaluations - wb.Log(RelationalEventId.QueryClientEvaluationWarning); - }); + // use in-memory database + //ConfigureTestingServices(services); + + // use real database + ConfigureProductionServices(services); + } - catch (System.Exception ex ) - { - var message = ex.Message; - } - }); - - // Add Identity DbContext - services.AddDbContext(options => - //options.UseInMemoryDatabase("Identity")); - options.UseSqlServer(Configuration.GetConnectionString("IdentityConnection"))); - - -// leave the rest of the method as-is ``` + 1. Ensure your connection strings in `appsettings.json` point to a local SQL Server instance. 2. Open a command prompt in the Web folder and execute the following commands: