public async Task Restore(string schemaScript) { InProgress = true; try { //var path = Path.Combine(backup.Path, backup.FileName); //if (!File.Exists(path)) throw new NotFoundException(); //var schemaScript = File.ReadAllText(path); using (var dbContext = new InfoRapContext()) { //await dbContext.Database.EnsureDeletedAsync(); //dbContext.SaveChanges(); var database = dbContext.Database; //await database.EnsureCreatedAsync(); // Works! //dbContext.SaveChanges(); #pragma warning disable CS0618 // Type or member is obsolete _ = await database.ExecuteSqlCommandAsync(schemaScript); #pragma warning restore CS0618 // Type or member is obsolete } } catch (Exception e) { throw e; } finally { InProgress = false; } }
public BaseRepository(InfoRapContext context) { _context = context; _dbSet = context.Set <T>(); }