Varigence, Inc.

Expand Minimize
Mist User Guide
Importing Tables using BimlScript

Mist allows you to import schema and table definitions from a database, along with updating your model with the current state of the definitions at each compile. To leverae the update capability, you will need to use BimlScript to author the import logic; the BimlScript is executed during each compile, obtaining the current state of schemas and tables.

To import a table, you first need to create a connection to the database. See Creating a Connection for more information.

Once the connection is created, you can import database assets by following these steps:

  1. Select the Home tab in the ribbon and click the BimlScript button.
    Biml Script Ribbon Button
  2. This creates a BimlFile that's added in the Logical View under BimlScript Library.
    BimlScript in Logical View
  3. Double click on the BimlFile to open the BimlScript designer.
    BimlScript Designer
  4. Enter your script in the Template Input editor. When executed, the script generates Biml for your imported assets. Clicking on the notification bar saves the script and displays the Biml, resulting from running the script, in the Expanded Template Output editor.
  5. For importing assets from the AdventureWorksLT database, you can copy and paste this BimlScript into the Template Input editor. You can also use this sample as a starting point for writing your own import script.
    <#@ template language="C#" hostspecific="True"#>
    <#@ import namespace="Varigence.Languages.Biml.Connection" #>
    <#@ import namespace="Varigence.Hadron.Extensions" #>
    <#@ import namespace="Varigence.Hadron.Extensions.SchemaManagement" #>
    
    <#+ public ImportResults Results
    { 
        get 
        { 
            return ((AstOleDbConnectionNode)RootNode.Connections["AdventureWorksLT"]).ImportDB();
        }
    }
    #> 
    
    <Biml xmlns="http://schemas.varigence.com/biml.xsd">
        <Schemas>
            <#=Results.SchemaNodes.GetBiml()#>
        </Schemas>
        <Tables> 
            <#=Results.TableNodes.GetBiml()#>
        </Tables>
    </Biml>
    
    1. The first thing to notice is that all code fragments are surrounded by required <# and #> characters.
    2. The first line is the required template directive. The language parameter depends on the language you're using; this example uses C#.
    3. The import directives specify namespaces, and are analogous to the C# using statement or the VB.NET imports statement.
    4. The Results property returns a collection of type ImportResults. The property's getter uses RootNode, which is the root of the project tree; all assets in your project can be reached from RootNode. The Connections collection returns the AdventureWorksLT connection and then calls its ImportDB method to perform the import.
    5. Within the Biml element, the Schemas and Tables lists are populated by retrieving the SchemaNodes and TableNodes collections from the Results property and calling GetBiml, which converts the returned schema and table items into Biml.
    6. To learn more about these functions, check out the Biml API documentation here.

  6. While writing the script, you can click on the notification bar to save the BimlScript and examine its output. The Update Preview ribbon button also refreshes the Output editor.
    Expanded BimlScript Output
    Update Preview Ribbon Button
  7. Once the output looks correct, press the Expand button in the ribbon to import the assets into your model.
    Expand BimlScript Ribbon Button
    Imported Assets in Logical View