protected IWorkbook InitializeWorkbook(IPersistenceLayer persistence, IPlatformService platformService) { IWorkbook workbook = null; if (persistence.HasSave) { try { workbook = persistence.Open(); } catch (Exception ex) { TrackingManagerHelper.Exception(ex, "Initialize workbook"); platformService.DeleteFileAsync(persistence.DatabaseFilename).Wait(1000); } } if (workbook == null) { persistence.Initialize(); workbook = this.CreateDefaultWorkbook(persistence.Context, platformService); persistence.Save(); } // important: read view from persistence and not from workbook as they are not loaded yet in the workbook ! if (persistence.Context.Views.Count() != DefaultDataCreator.ViewCount) { CreateDefaultViews(workbook); } workbook.Initialize(); Ioc.RegisterInstance <IWorkbook, Workbook>((Workbook)workbook); return(workbook); }