diff --git a/.github/workflows/deployapi.yml b/.github/workflows/deployapi.yml index ce14923..2ce5d74 100644 --- a/.github/workflows/deployapi.yml +++ b/.github/workflows/deployapi.yml @@ -22,6 +22,14 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: '9.x' + + - name: Update database + run: | + dotnet tool install --global dotnet-ef --version 9.* + dotnet tool restore + dotnet ef --project TickAPI/TickAPI/TickAPI.csproj database update + env: + ConnectionStrings__DefaultConnection: ${{ secrets.RESELLIO_DB_CONNECTION_STRING }} - name: Build with dotnet run: dotnet build TickAPI/TickAPI/TickAPI.csproj --configuration Release @@ -34,6 +42,7 @@ jobs: with: name: .net-app path: ${{env.DOTNET_ROOT}}/myapp + deploy: runs-on: windows-latest diff --git a/TickAPI/TickAPI/Program.cs b/TickAPI/TickAPI/Program.cs index 08779cd..9e7e07b 100644 --- a/TickAPI/TickAPI/Program.cs +++ b/TickAPI/TickAPI/Program.cs @@ -146,7 +146,12 @@ builder.Services.AddDbContext(options => { - options.UseSqlServer(builder.Configuration.GetConnectionString("ResellioDatabase")); + options.UseSqlServer(builder.Configuration.GetConnectionString("ResellioDatabase"), + sqlOptions => + sqlOptions.EnableRetryOnFailure( + maxRetryCount: 5, + maxRetryDelay: TimeSpan.FromSeconds(30), + errorNumbersToAdd: null)); }); // Create CORS policy