Share via


How to: Get Started with Using the Administration Object Model

Although you can use XML to create your metadata, the Business Data Catalog offers an Administration object model that you can use to create, edit, and delete metadata. The main purpose of the Administration object model is to enable you to write tools that make it easy to create and manage metadata.

The Administration object model follows the Business Data Catalog Metadata Model. It defines all 13 metadata objects and provides methods that enable you to do the following:

  • Create and delete metadata objects.

  • Programmatically perform other administrative tasks related to metadata, such as importing metadata into the Business Data Catalog and configuring security on the metadata objects.

The Administration object model is defined in the Microsoft.Office.Server.ApplicationRegistry.Administration namespace in the Microsoft.SharePoint.Portal.dll.

Important

The Runtime object model also defines the metadata objects, but it only allows you to read them—not create, edit, or delete them. Therefore, you should use the Administration object model when you want to edit the metadata. Use the Runtime object model if you only want to read the metadata, because it is cached and fast. Conversely, the Administration object model has relatively high latency and a delay of a few seconds before the Business Data Catalog updates the cache in all the front-end Web servers (Front-end Web Server) and application servers in the deployment.

Following are the top three tasks that you can perform with the Administration object model:

  • Creating an Lob system, entity, and method.

  • Creating access control lists (ACLs) and setting security for the metadata objects.

  • Importing metadata into the Business Data Catalog.

In this section, we look at how to write simple Microsoft Visual Studio 2005 console applications in Microsoft Visual C# that use the Administration object model to perform the top three tasks.

ApplicationRegistry is the top-level object in the Administration object model. Its static Instance property represents and acts as the entry point to the Business Data Catalog. This property enables you to create, read, update, and delete all the metadata objects, including LOB systems, entities, and methods.

Note

The Business Data Catalog feature was named Application Registry originally, but is now named Business Data Catalog. This is why you will find the term ApplicationRegistry in the object model. When you see this term, remember that it refers to the Business Data Catalog.

Example

As you might already know, the Business Data Catalog is implemented as a Microsoft Office SharePoint Server 2007 shared service and is shared across a Shared Service Provider. Therefore, before you can use the ApplicationRegistry object, you must reference the Shared Service Provider associated with the Business Data Catalog.

The following code example shows how to set the Shared Service Provider for use with the Business Data Catalog.

After you specify the Shared Service Provider, you can use the ApplicationRegistry object to create and manage the LobSystemInstance objects registered with the Business Data Catalog. The CreateLobSystemAndInstance method shows how to use the object model to create an LobSystem instance.

Prerequisites

  • Ensure a Shared Service Provider is already created.

  • Replace the constant value EnterYourSSPNameHere in the code with the name of your Shared Resource Provider.

Project References

Add the following Project References in your console application code project before running this sample:

  • Microsoft.SharePoint

  • Microsoft.SharePoint.Portal

  • Microsoft.Office.Server

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Office.Server.ApplicationRegistry.Administration;
using Microsoft.Office.Server.ApplicationRegistry.Infrastructure;
using WSSAdmin = Microsoft.SharePoint.Administration;
using OSSAdmin = Microsoft.Office.Server.Administration;

namespace Microsoft.SDK.SharePointServer.Samples
{
    class GetStartedAndCreateSystem
    {
        const string yourSSPName ="EnterYourSSPNameHere";

        static void Main(string[] args)
        {
            SetupBDC();
            CreateLobSystemAndInstance();
            Console.WriteLine("Press any key to exit...");
            Console.Read();
        }
        static void SetupBDC()
        {
            SqlSessionProvider.Instance().SetSharedResourceProviderToUse(yourSSPName);
        }
        static void CreateLobSystemAndInstance()
        {
            LobSystem system = ApplicationRegistry.Instance.LobSystems.Create("AdventureWorksSampleFromCode", true, "Microsoft.Office.Server.ApplicationRegistry.SystemSpecific.Db.DbSystemUtility", "Microsoft.Office.Server.ApplicationRegistry.SystemSpecific.Db.DbConnectionManager", "Microsoft.Office.Server.ApplicationRegistry.SystemSpecific.Db.DbEntityInstance");

            LobSystemInstance sysInstance = system.LobSystemInstances.Create("AdventureWorksSampleFromCode", true);

            sysInstance.Properties.Add("AuthenticationMode", (Int32)Microsoft.Office.Server.ApplicationRegistry.SystemSpecific.Db.DbAuthenticationMode.PassThrough);

            sysInstance.Properties.Add("DatabaseAccessProvider", (Int32)Microsoft.Office.Server.ApplicationRegistry.SystemSpecific.Db.DbAccessProvider.SqlServer);

            sysInstance.Properties.Add("RdbConnection Data Source", "YourAdvWorks2000ServerNameHere");

            sysInstance.Properties.Add("RdbConnection Initial Catalog", "AdventureWorks2000");

            sysInstance.Properties.Add("RdbConnection Integrated Security", "SSPI");

            sysInstance.Properties.Add("RdbConnection Pooling", "false");

            sysInstance.Properties.Add("WildCardCharacter", "%");

            sysInstance.Update();
            Console.WriteLine("Created a system instance successfully.");
        }
    }
}

See Also

Concepts

Business Data Catalog: Metadata Model