Assigning Object Identifiers

Meta Data Services Programming

Meta Data Services Programming

Assigning Object Identifiers

When you install an information model in a repository, the repository engine creates a number of objects to represent the classes, interfaces, collection types, properties, and relationship types of that model. The assignment of an object identifier to an object occurs when the object definition is inserted into a repository database. If you are installing an information model using the model installer, the repository engine assigns the identifier.

If you are inserting an information model programmatically, you can still let the repository engine assign an identifier automatically, or you can provide an object identifier manually. To let the repository engine assign an identifier for a programmatically inserted object, set the input parameter for the object identifier to OBJID_NULL.

In most cases, you should let the repository engine assign object identifiers. The exception is when you are inserting a replica of an object represented in one Microsoft® SQL Server™ 2000 Meta Data Services repository database into another Meta Data Services repository. For each type definition object that you copy to the new repository, you should use the object identifier that was assigned to that object in the existing repository. This will ensure that the type definition has the same identity in both repositories.

If you explicitly assign object identifiers for your definition objects, you must ensure that the object identifiers are unique across all repositories. The following steps are recommended to guarantee such uniqueness:

  1. Generate a single unused GUID and use it for the GUID portion (the first 16 bytes) of all definition object identifiers for the information model.

  2. Using the CreateObject method, manually assign unique local identifiers for each definition object in the information model.
Using Guidgen

When creating object identifiers for your information model, you can use the Guidgen.exe program to create an unused GUID, and use the DEFINE_OBJID macro to create the object identifiers. Given a GUID and a unique number for an object, the macro will equate the symbolic name to the value for the object identifier. Use the DEFINE_OBJID macro (which is provided for both Microsoft Visual C++® and Microsoft Visual Basic® programmers) to avoid incompatibility problems later.

See Also

Installing Information Models

IRepository::CreateObject

Object-Version Identifiers and Internal Object-Version Identifiers

Repository CreateObject Method

Repository Identifiers