Commit e1acb4e 1 parent d199452 commit e1acb4e Copy full SHA for e1acb4e
File tree 2 files changed +4
-13
lines changed
2 files changed +4
-13
lines changed Original file line number Diff line number Diff line change 1
- using System . Threading ;
2
- using MaintenanceLog . Data ;
1
+ using MaintenanceLog . Data ;
3
2
using Microsoft . EntityFrameworkCore ;
4
- using Microsoft . EntityFrameworkCore . Migrations ;
5
3
6
4
namespace MaintenanceLog ;
7
5
8
6
public static class DatabaseUtility
9
7
{
10
- public static async Task EnsureDbCreatedAndSeedWithDefaults ( DbContextOptions < ApplicationDbContext > options , IMigrator migrator )
8
+ public static async Task EnsureDbCreatedAndSeedWithDefaults ( DbContextOptions < ApplicationDbContext > options )
11
9
{
12
10
var factory = new LoggerFactory ( ) ;
13
11
var builder = new DbContextOptionsBuilder < ApplicationDbContext > ( options )
14
12
. UseLoggerFactory ( factory ) ;
15
13
16
14
using var context = new ApplicationDbContext ( builder . Options ) ;
17
15
18
- //if (!await context.Database.EnsureCreatedAsync())
19
- //{
20
- // Console.WriteLine("Database already exists or was not otherwise created.");
21
- //}
22
-
23
16
try
24
17
{
25
18
// not good with distributed UI... but for now...
Original file line number Diff line number Diff line change 92
92
93
93
// This section sets up and seeds the database. Seeding is NOT normally
94
94
// handled this way in production.
95
- await using var scope = app . Services . GetRequiredService < IServiceScopeFactory > ( ) . CreateAsyncScope ( ) ;
96
- var options = scope . ServiceProvider . GetRequiredService < DbContextOptions < ApplicationDbContext > > ( ) ;
97
- var migrator = scope . ServiceProvider . GetService < IMigrator > ( ) ;
98
- await MaintenanceLog . DatabaseUtility . EnsureDbCreatedAndSeedWithDefaults ( options , migrator ) ;
95
+ var options = app . Services . GetRequiredService < DbContextOptions < ApplicationDbContext > > ( ) ;
96
+ await MaintenanceLog . DatabaseUtility . EnsureDbCreatedAndSeedWithDefaults ( options ) ;
99
97
100
98
app . MapControllers ( ) ;
101
99
You can’t perform that action at this time.
0 commit comments