File tree 3 files changed +17
-1
lines changed
ClubService.Domain/Repository
ClubService.Infrastructure/Logging
3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 1
1
using ClubService . API ;
2
2
using ClubService . API . ApplicationConfigurations ;
3
+ using ClubService . Domain . Repository ;
3
4
using ClubService . Infrastructure . DbContexts ;
4
5
using Microsoft . AspNetCore . Authentication ;
5
6
using Microsoft . EntityFrameworkCore ;
66
67
app . UseSwaggerUI ( options => { options . SwaggerEndpoint ( "/swagger/v1/swagger.json" , "ClubServiceV1" ) ; } ) ;
67
68
68
69
await eventStoreDbContext . Database . EnsureCreatedAsync ( ) ;
69
- await eventStoreDbContext . SeedTestData ( ) ;
70
+
71
+ try
72
+ {
73
+ await eventStoreDbContext . SeedTestData ( ) ;
74
+ }
75
+ catch ( DbUpdateException )
76
+ {
77
+ var logger = services . GetRequiredService < ILoggerService < Program > > ( ) ;
78
+ logger . LogDuplicateSeedData ( ) ;
79
+ }
70
80
71
81
await readStoreDbContext . Database . EnsureDeletedAsync ( ) ;
72
82
await readStoreDbContext . Database . EnsureCreatedAsync ( ) ;
Original file line number Diff line number Diff line change @@ -64,4 +64,5 @@ public interface ILoggerService<T>
64
64
void LogJsonMissingProperties ( string jsonValue ) ;
65
65
void LogEmailMessageRelayStop ( ) ;
66
66
void LogSystemOperatorRegistered ( Guid id ) ;
67
+ void LogDuplicateSeedData ( ) ;
67
68
}
Original file line number Diff line number Diff line change @@ -320,4 +320,9 @@ public void LogSystemOperatorRegistered(Guid id)
320
320
{
321
321
logger . LogInformation ( "Registered system operator with id '{id}'." , id ) ;
322
322
}
323
+
324
+ public void LogDuplicateSeedData ( )
325
+ {
326
+ logger . LogInformation ( "Seed data already seeded" ) ;
327
+ }
323
328
}
You can’t perform that action at this time.
0 commit comments