1
- // Copyright (c) .NET Foundation. All rights reserved.
2
- // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
1
+ // Copyright (c) .NET Foundation. All rights reserved.
2
+ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
3
4
4
using System ;
5
5
using System . Data . Common ;
@@ -34,7 +34,7 @@ public Startup(IApplicationEnvironment appEnv, IHostingEnvironment hostingEnv, S
34
34
}
35
35
36
36
public IConfigurationRoot Configuration { get ; set ; }
37
-
37
+
38
38
public Scenarios Scenarios { get ; }
39
39
40
40
public void ConfigureServices ( IServiceCollection services )
@@ -52,7 +52,7 @@ public void ConfigureServices(IServiceCollection services)
52
52
. AddDbContext < ApplicationDbContext > ( ) ;
53
53
54
54
if ( Scenarios . Any ( "Raw" ) || Scenarios . Any ( "Dapper" ) )
55
- {
55
+ {
56
56
// TODO: Add support for plugging in different DbProviderFactory implementations via configuration
57
57
services . AddSingleton < DbProviderFactory > ( SqlClientFactory . Instance ) ;
58
58
}
@@ -81,7 +81,7 @@ public void ConfigureServices(IServiceCollection services)
81
81
{
82
82
var mvcBuilder = services . AddMvcCore ( )
83
83
. AddControllersAsServices ( typeof ( Startup ) . GetTypeInfo ( ) . Assembly ) ;
84
-
84
+
85
85
if ( Scenarios . MvcApis )
86
86
{
87
87
mvcBuilder . AddJsonFormatters ( ) ;
@@ -96,7 +96,7 @@ public void ConfigureServices(IServiceCollection services)
96
96
}
97
97
}
98
98
99
- public void Configure ( IApplicationBuilder app , ApplicationDbSeeder dbSeeder )
99
+ public void Configure ( IApplicationBuilder app , ApplicationDbSeeder dbSeeder , ApplicationDbContext dbContext )
100
100
{
101
101
app . UseErrorHandler ( ) ;
102
102
@@ -160,6 +160,8 @@ public void Configure(IApplicationBuilder app, ApplicationDbSeeder dbSeeder)
160
160
161
161
if ( Scenarios . Any ( "Db" ) )
162
162
{
163
+ dbContext . Database . EnsureCreated ( ) ;
164
+
163
165
if ( ! dbSeeder . Seed ( ) )
164
166
{
165
167
Environment . Exit ( 1 ) ;
0 commit comments