You are here: Configuration > Common Configuration > Allow Version Updates

Allow Version Updates

The db4o database file format is a subject to change to allow progress for performance and additional features. db4o does not support downgrades back to previous versions of database files. In order to prevent accidental upgrades when using different db4o versions, db4o does not upgrade databases by default. Database upgrading can be turned on with the following configuration switch:

IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
configuration.Common.AllowVersionUpdates = true;

// reopen and close the database to do the update
IObjectContainer container = Db4oEmbedded.OpenFile(configuration, DatabaseFile);
container.Close();
CommonConfigurationExamples.cs: Update the database-format
Dim configuration As IEmbeddedConfiguration = Db4oEmbedded.NewConfiguration()
configuration.Common.AllowVersionUpdates = True

' reopen and close the database to do the update
Dim container As IObjectContainer = Db4oEmbedded.OpenFile(configuration, DatabaseFile)
container.Close()
CommonConfigurationExamples.vb: Update the database-format

Please note that, once the database file version is updated, there is no way to get back to the older version. When a database file is opened successfully with the new db4o version, the upgrade of the file will take place automatically. You can simply upgrade database files by opening and closing a db4o database once.

Recommendations for upgrading: