/// <summary> /// <para>Method to create a connection to the to the database.</para> /// <para>The database is ensure to be created on connection request.</para> /// </summary> /// <exception cref="InvalidOperationException">Exception thrown if database connection fail.</exception> private bool Connect() { try { var options = new DbContextOptionsBuilder <DatabaseContextCore>(); options.UseSqlite(GetConnectionString()); context = new DatabaseContextCore(options.Options); return(context.Database.EnsureCreated()); } catch (Exception e) { string s = $"Cannot open database : {dbname}"; log.Fatal(s); log.Fatal(e.Output(), e); throw; } }
/// <summary> /// Method to dispose object and its resources. /// </summary> /// <param name="disposing">Dispose object resources ?</param> protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { // TODO: supprimer l'état managé (objets managés). if (context != null) { context.Dispose(); context = null; } } // TODO: libérer les ressources non managées (objets non managés) et remplacer un finaliseur ci-dessous. // TODO: définir les champs de grande taille avec la valeur Null. disposedValue = true; } }