3 min read

A quick sample: how to customize your database schema view visually?

When you want to change your database schema tree, Metadata Container Editor lets you do this without coding to experiment with the tree structure faster.
A quick sample: how to customize your database schema view visually?

Cutting the long story short, suppose you want to change your schema name and display a folder with only its views inside it.

I will use the Metadata Container Editor tool to cope with this tasks in a few clicks.

Metadata Container Editor lets create and edit the content you see in the database schema tree without coding. It is included in all versions of Active Query Builder. Its main window looks as follows:

Metadata Container Editor Main window

​There are two trees, and one properties pane at the right that displays properties of the focused node of one tree or another.

The left-hand tree displays the content of MetadataContainer which reflects the physical database schema. We highly don't recommend renaming or moving objects ​in it. You can hide some of them or remove unwanted ones. Also, you can specify alternate friendly names for real objects, so the user can quickly catch what data it contains.

The tree at the center displays the MetadataStructure object. It is used to customize the arrangement of objects within the tree. If not filled, it reflects the physical structure according to the QueryBuilder.MetadataStructureOptions settings (there you can define grouping by types and namespaces, etc.)

By default, both MetadataContainer and MetadataStructure objects are filled during the metadata loading process automatically, but you can override this by loading them from pre-generated XML files. You may load just the MetadataStructure from XML and leave the MetadataContainer to be filled automatically, or vice versa.

So, to cope with the given task you can do the following.

1. Open the Metadata Container Editor, select the "Metadata Container" - "Load from database" menu item, follow the Metadata Load Wizard steps and get your database schema loaded to the right tree.

2. Add the following nodes to the Metadata Structure:

- Disable automatic loading of child items for the Root node.

​- Drag your schema from the Metadata Container to the Structure tree and disable loading for it, rename it as you need.

​- Add a new item and set its caption as needed (I named it "OnlyViews"),

​- For this node, create a metadata filter and define it to see only objects of View type.

​When you finished, you can click the "Preview" button and see how your tree will look for the end-user.

​Of course, you can do the same in code. But this tool lets you experiment with the tree structure faster. You can read this article to learn how to tune the MetadataStructure to suit your needs: Customizing the Database Schema Tree structure.