private void way2ItemMetadataLoading(object sender, MetadataItem item, MetadataType types)
        {
            switch (item.Type)
            {
            case MetadataType.Root:
                if (types.Contains(MetadataType.Schema))
                {
                    // only one "dbo" schema should be at the root level
                    if (item.Items.FindItem <MetadataNamespace>("dbo", MetadataType.Schema) == null)
                    {
                        item.AddSchema("dbo");
                    }
                }
                break;

            case MetadataType.Schema:
                if (item.Name == "dbo" && types.Contains(MetadataType.Table))
                {
                    item.AddTable("Orders");
                    item.AddTable("Order Details");
                }
                break;

            case MetadataType.Table:
                if (item.Name == "Orders")
                {
                    if (types.Contains(MetadataType.Field))
                    {
                        item.AddField("OrderId");
                        item.AddField("CustomerId");
                    }
                }
                else if (item.Name == "Order Details")
                {
                    if (types.Contains(MetadataType.Field))
                    {
                        item.AddField("OrderId");
                        item.AddField("ProductId");
                    }

                    if (types.Contains(MetadataType.ForeignKey))
                    {
                        MetadataForeignKey foreignKey = item.AddForeignKey("OrderDetailsToOrder");
                        foreignKey.Fields.Add("OrderId");
                        foreignKey.ReferencedFields.Add("OrderId");
                        using (MetadataQualifiedName name = new MetadataQualifiedName())
                        {
                            name.Add("Orders");
                            name.Add("dbo");

                            foreignKey.ReferencedObjectName = name;
                        }
                    }
                }
                break;
            }

            item.Items.SetLoaded(types, true);
        }
        private void way2ItemMetadataLoading(object sender, MetadataItem item, MetadataType types)
        {
            switch (item.Type)
            {
            case MetadataType.Root:
                if ((types & MetadataType.Schema) > 0)
                {
                    item.AddSchema("dbo");
                }
                break;

            case MetadataType.Schema:
                if ((item.Name == "dbo") && (types & MetadataType.Table) > 0)
                {
                    item.AddTable("Orders");
                    item.AddTable("Order Details");
                }
                break;

            case MetadataType.Table:
                if (item.Name == "Orders")
                {
                    if ((types & MetadataType.Field) > 0)
                    {
                        item.AddField("OrderId");
                        item.AddField("CustomerId");
                    }
                }
                else if (item.Name == "Order Details")
                {
                    if ((types & MetadataType.Field) > 0)
                    {
                        item.AddField("OrderId");
                        item.AddField("ProductId");
                    }

                    if ((types & MetadataType.ForeignKey) > 0)
                    {
                        MetadataForeignKey foreignKey = item.AddForeignKey("OrderDetailsToOrder");
                        foreignKey.Fields.Add("OrderId");
                        foreignKey.ReferencedFields.Add("OrderId");
                        using (MetadataQualifiedName name = new MetadataQualifiedName())
                        {
                            name.Add("Orders");
                            name.Add("dbo");

                            foreignKey.ReferencedObjectName = name;
                        }
                    }
                }
                break;
            }

            item.Items.SetLoaded(types, true);
        }