|
|
@ -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 |
|
|
### 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) |
|
|
public void ConfigureDevelopmentServices(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<CatalogContext>(c => |
|
|
|
|
|
{ |
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
{ |
|
|
//c.UseInMemoryDatabase("Catalog"); |
|
|
// use in-memory database |
|
|
c.UseSqlServer(Configuration.GetConnectionString("CatalogConnection")); |
|
|
//ConfigureTestingServices(services); |
|
|
c.ConfigureWarnings(wb => |
|
|
|
|
|
{ |
|
|
|
|
|
//By default, in this application, we don't want to have client evaluations |
|
|
|
|
|
wb.Log(RelationalEventId.QueryClientEvaluationWarning); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
catch (System.Exception ex ) |
|
|
|
|
|
{ |
|
|
|
|
|
var message = ex.Message; |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// Add Identity DbContext |
|
|
// use real database |
|
|
services.AddDbContext<AppIdentityDbContext>(options => |
|
|
ConfigureProductionServices(services); |
|
|
//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. |
|
|
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: |
|
|
2. Open a command prompt in the Web folder and execute the following commands: |
|
|
|