File tree Expand file tree Collapse file tree 4 files changed +15
-17
lines changed Expand file tree Collapse file tree 4 files changed +15
-17
lines changed Original file line number Diff line number Diff line change 33IDistributedApplicationBuilder  builder  =  DistributedApplication . CreateBuilder ( args ) ; 
44
55IResourceBuilder < PostgresDatabaseResource >  database  =  builder 
6-     . AddPostgres ( "database " ) 
6+     . AddPostgres ( "SQL-Database " ) 
77    . WithImage ( "postgres:17" ) 
8+     . WithHostPort ( 5432 ) 
89    . WithBindMount ( "../../.containers/db" ,  "/var/lib/postgresql/data" ) 
910    . AddDatabase ( "clean-architecture" ) ; 
1011
1112IResourceBuilder < PapercutSmtpContainerResource >  papercut  =  builder 
12-     . AddPapercutSmtp ( "papercut"  ) 
13+     . AddPapercutSmtp ( "SMTP-Papercut"  ,   httpPort :   2115 ,   smtpPort :   1337 ) 
1314    . WithHttpHealthCheck ( path :  "/" ) ; 
1415
15- builder . AddProject < Projects . Web_Api > ( "web-api " ) 
16+ builder . AddProject < Projects . Web_Api > ( "Web-API " ) 
1617    . WithEnvironment ( "ConnectionStrings__Database" ,  database ) 
1718    . WithReference ( papercut ) 
1819    . WithReference ( database ) 
Original file line number Diff line number Diff line change @@ -17,31 +17,18 @@ public sealed class ApplicationDbContext(DbContextOptions<ApplicationDbContext>
1717    :  DbContext ( options ) ,  IApplicationDbContext 
1818{ 
1919    public  DbSet < User >  Users  {  get ;  set ;  } 
20- 
2120    public  DbSet < Address >  Addresss  {  get ;  set ;  } 
22- 
2321    public  DbSet < Cart >  Carts  {  get ;  set ;  } 
24- 
2522    public  DbSet < CartItem >  CartItems  {  get ;  set ;  } 
26- 
2723    public  DbSet < Category >  Categories  {  get ;  set ;  } 
28- 
2924    public  DbSet < Order >  Orders  {  get ;  set ;  } 
30- 
3125    public  DbSet < OrderItem >  OrderItems  {  get ;  set ;  } 
32- 
3326    public  DbSet < Product >  Products  {  get ;  set ;  } 
34- 
3527    public  DbSet < Review >  Reviews  {  get ;  set ;  } 
36- 
3728    public  DbSet < Inventory >  Inventories  {  get ;  set ;  } 
38- 
3929    public  DbSet < EmailVerificationToken >  EmailVerificationTokens  {  get ;  set ;  } 
40- 
4130    public  DbSet < Role >  Roles  {  get ;  set ;  } 
42- 
4331    public  DbSet < UserClaim >  UserClaims  {  get ;  set ;  } 
44- 
4532    public  DbSet < RoleClaim >  UserRoles  {  get ;  set ;  } 
4633
4734    protected  override  void  OnModelCreating ( ModelBuilder  modelBuilder ) 
Original file line number Diff line number Diff line change 1919	<InternalsVisibleTo  Include =" ArchitectureTests"   />
2020  </ItemGroup >
2121
22+   <ItemGroup >
23+     <Folder  Include =" Database\Migrations\"   />
24+   </ItemGroup >
25+ 
2226</Project >
Original file line number Diff line number Diff line change @@ -11,7 +11,13 @@ public static void ApplyMigrations(this IApplicationBuilder app)
1111
1212        using  ApplicationDbContext  dbContext  = 
1313            scope . ServiceProvider . GetRequiredService < ApplicationDbContext > ( ) ; 
14+         try 
15+         { 
16+             dbContext . Database . Migrate ( ) ; 
17+         }  catch 
18+         { 
19+             //App can continue even if migration fails 
20+         } 
1421
15-         dbContext . Database . Migrate ( ) ; 
1622    } 
1723} 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments