[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.
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
From the Start Menu, click Run.
In the Run dialog, type cmd. Click the OK button to launch a command prompt.
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"
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
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".
At the command prompt, type the following command and press ENTER.
notepad.exe Employee_Instances.m
At the dialog, click Yes to create the new file.
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",
}
}
}
On the File menu, click Save.
Close Notepad.
To load the Employee instances into the "Oslo" repository
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
Use the dir command to verify the creation of the Employees_Instances.mx image file.
Install the image into the local “Oslo” repository database.
mx.exe install Employee_Instances.mx /database:Repository
To verify the new Employee instances
At the command prompt, type sqlcmd.exe and press ENTER.
Type the following lines, pressing ENTER between each line.
use Repository
go
select * from [HumanResources].[Employees]
go
Verify that the new data has been added to the model. There should be two employees returned from the query.
Type quit to exit.
To remove the HumanResourcesExampleFolder Folder
At the command prompt, type the following command and press ENTER.
mx.exe dropFolder Applications/HumanResourcesFolder /database:Repository
See Also