Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
Microsoft Oslo
Oslo SDK
 How to: Create data using "M"
How to: Create data using "M"
[This is prerelease documentation and is subject to change in future releases. Blank topics are included as placeholders.]

In addition to creating models, Microsoft code name “M” is able to add model instance data to an existing model in the code name “Oslo” repository. This topic demonstrates how to insert rows into the database using “M” and the code name “Oslo” SDK tools.

Dd861712.Important(en-us,VS.85).gif Note:
This topic uses a HumanResources model. For more information about how to create this model and install it in the “Oslo” repository, see How to: Install the HumanResources Sample Model using "M".

In this tutorial, you will perform the following tasks.

  • Use Mx.exe to create a new Folder for containing Employees.

  • Create an “M” file to define new employee instances.

  • Compile and load the model instances into the “Oslo” repository database.

  • Use Mx.exe to remove the Folder for this example.

To create a new "Oslo" repository Folder

  1. From the Start Menu, click Run.

  2. In the Run dialog, type cmd. Click the OK button to launch a command prompt.

  3. Modify the PATH environment variable to include the path to the code name “Oslo” SDK tools. By default, the code name “Oslo” SDK tools install to the C:\Program Files\Microsoft Oslo SDK 1.0\Bin directory.

    set PATH=%PATH%;"%PROGRAMFILES%\Microsoft Oslo\1.0\bin"
  4. Use the following command to create a new “Oslo” repository Folder named HumanResourcesFolder. The system-defined Applications Folder is the parent Folder.

    mx createFolder Applications/HumanResourcesFolder /database:Repository

To create "M" Employee instances

  1. At the same command line, navigate to the directory that contains the previously created Employees.mx file. For more information about how to create this image file, see How to: Install the HumanResources Sample Model using "M".

  2. At the command prompt, type the following command and press ENTER.

    notepad.exe Employee_Instances.m
  3. At the dialog, click Yes to create the new file.

  4. In notepad, add the following “M” instance definitions. This inserts two employees, John and Susan. The Id field is not provided, as it is automatically assigned. The PathsFolder function returns an identifier for the Folder specified by the path, Applications/HumanResourcesFolder. This path matches the Folder created in the previous step. The PathsFolder function is defined in the Repository.Item model, so the code imports the Repository.Item module.

    module HumanResources
    {
        import Repository.Item;
    
        Employees
        {
            FirstEmployee
            {
                Folder => PathsFolder("Applications/HumanResourcesFolder"),
                Name => "John",
            },
            SecondEmployee
            {
                Folder => PathsFolder("Applications/HumanResourcesFolder"),
                Name => "Susan",
            }
        }
    }
  5. On the File menu, click Save.

  6. Close Notepad.

To load the Employee instances into the "Oslo" repository

  1. At the original command prompt, use the “M” compiler to create an image file for the instance data. Note that you must reference both the Employees.mx image file and the Repository.mx image file to resolve the dependencies in the Employee_Instances.m source code.

    m.exe Employee_Instances.m /target:Repository /package:Image /out:Employee_Instances.mx /r:Employees.mx /r:"C:\Program Files\Microsoft Oslo\1.0\bin\Repository.mx" /nowarn:3906
  2. Use the dir command to verify the creation of the Employees_Instances.mx image file.

  3. Install the image into the local “Oslo” repository database.

    mx.exe install Employee_Instances.mx /database:Repository

To verify the new Employee instances

  1. At the command prompt, type sqlcmd.exe and press ENTER.

    sqlcmd.exe
  2. Type the following lines, pressing ENTER between each line.

    use Repository
    go
    select * from [HumanResources].[Employees]
    go
  3. Verify that the new data has been added to the model. There should be two employees returned from the query.

  4. Type quit to exit.

To remove the HumanResourcesExampleFolder Folder

  1. At the command prompt, type the following command and press ENTER.

    mx.exe dropFolder Applications/HumanResourcesFolder /database:Repository

See Also

Fill out a survey about this topic for Microsoft.
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker