HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubNuGetDev CommunitySubmit a ticketLog In

MetaClassManager class

The entry point to the meta-model, available from the DataContext.MetaModel property.

Use the MetaModel to get meta-classes, registered meta-types and relationships and to create and delete meta-classes. Also, MetaClassManager includes the static events MetaClassCreating, MetaClassCreated, MetaClassDeleting, MetaClassDeleted, MetaFieldCreating, MetaFieldCreated, MetaFieldDeleting, MetaFieldDeleted. You can subscribe to these events to get information about external meta-model modifications.

The Business Meta-Model can enter these modes:

  • Runtime. The default mode is where users can work with data only.
  • Design. Enables users to modify the meta-model.

Runtime mode is a default state allowing for working with objects. You can create, load, update, and delete entity objects in this mode.



You can modify a meta-model only in Design mode, so if you want to change the meta-model, activate Design mode. Design mode creates a local copy of the meta-model and commits modifications only after final commit.

Upon instantiating a MetaClassManagerEditScope by the calling MetaClassManager.BeginEdit statement, the meta-model manager determines which mode to participate in. Once determined, the scope participates in that edit scope. You can obtain a reference to the ambient edit scope by calling the Current property of the MetaClassManagerEditScope class.

Suppose no exception occurs within the transaction scope (between initializing the MetaClassManagerEditScope object and calling its Dispose method). In that case, the transaction in which the scope participates is allowed to proceed. If an exception occurs within the edit scope, the transaction it participates in is rolled back.

When your application completes the work needed in a transaction, call the SaveChanges method only once to inform that meta-model manager that it can commit the transaction. Failing to call this method aborts the transaction. Afterwards, the SaveChanges meta-model modifications are available to all users. A call to the Dispose method marks the end of the edit scope. Exceptions that occur after calling this method may not affect the transaction.

Example: The Open meta-model edit scope

// Open Meta-model edit scope
    using (MetaClassManagerEditScope scope =
    // Modify meta-model here
    // Save Changes