Initial Setup

When replicating objects to and from a db4o database, we need to enable UUIDs and VersionNumbers.

UUIDs are object IDs that are unique across all databases created with db4o. That is achieved by having the database creation timestamp as part of its objects UUIDs. The db4o UUID contains two parts. The first part contains an object ID. The second part identifies the database that originally created this ID.  More information on the UUIDs can be found in the db4o reference documentation.
The replication system will use the version number to invisibly tell when an object was last replicated, and if any changes have been made to the object since it was last replicated. An object's version number indicates the last time an object was modified. It is the database version at the moment of the modification.

ReplicationExample.cs: ConfigureReplication
1public static void ConfigureReplication() 2 { 3 Db4oFactory.Configure().GenerateUUIDs(ConfigScope.GLOBALLY); 4 Db4oFactory.Configure().GenerateVersionNumbers(ConfigScope.GLOBALLY); 5 }

ReplicationExample.vb: ConfigureReplication
1Public Shared Sub ConfigureReplication() 2 Db4oFactory.Configure().GenerateUUIDs(ConfigScope.GLOBALLY) 3 Db4oFactory.Configure().GenerateVersionNumbers(ConfigScope.GLOBALLY) 4 End Sub

The above settings can also be applied to a specific class object, which needs to be replicated. This can help to improve the performance if only selected classes need to be replicated:

ReplicationExample.cs: ConfigureReplicationPilot
1public static void ConfigureReplicationPilot() 2 { 3 Db4oFactory.Configure().ObjectClass(typeof(Pilot)).GenerateUUIDs(true); 4 Db4oFactory.Configure().ObjectClass(typeof(Pilot)).GenerateVersionNumbers(true); 5 }

ReplicationExample.vb: ConfigureReplicationPilot
1Public Shared Sub ConfigureReplicationPilot() 2 Db4oFactory.Configure().ObjectClass(GetType(Pilot)).GenerateUUIDs(True) 3 Db4oFactory.Configure().ObjectClass(GetType(Pilot)).GenerateVersionNumbers(True) 4 End Sub