private void EnsureDbMigration(BorrowedGamesContext dbContext, ILogger <Startup> logger, int tentatives = 1) { logger.LogInformation($"Attempting to Migrate Database. Tentative: {tentatives}"); int count = tentatives; try { dbContext.Database.Migrate(); } catch (Exception ex) { Thread.Sleep(30000); count += 1; if (count > 5) { throw ex; } EnsureDbMigration(dbContext, logger, count); } }
public UserRepository(BorrowedGamesContext context) : base(context) { }
public BaseRepository(BorrowedGamesContext context) { _context = context; dbSet = context.Set <T>(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger <Startup> logger, BorrowedGamesContext borrowedGamesContext) { EnsureDbMigration(borrowedGamesContext, logger); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRouting(); app.UseCors(c => c.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); app.UseSwagger(c => { c.SerializeAsV2 = true; }); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Invillia API"); c.RoutePrefix = string.Empty; }); }
public BorrowedGameRepository(BorrowedGamesContext options) : base(options) { }
public UnityOfWork(BorrowedGamesContext dbContext) { _dbcontext = dbContext; }