Go get it here!
Yes! Oslo May 2009 CTP is out!
May 27, 2009 by StefanBook tip: RESTful .NET
April 26, 2009 by StefanAs I haven’t yet had a lot of exposure to how to build REST Web Services with WCF I was very lucky to find a book called RESTful .NET by Jon Flanders. After reading this book I enjoyed playing around with the MUrl which is a DSL for RESTful clients and I am looking really forward trying out the MService – a DSL for RESTful services, which I believe will be shipped with the next OSLO CTP?
The M tip of the day: Defining a simple tree
March 12, 2009 by StefanWith a simple tree I mean a self-referencing one-to-many relationship without a strategy to handle cycles between linked instances. An excellent MSDN-article on that subject is found here.
module Tree
{
type Person
{
Id : Integer32 = AutoNumber();
Name : Text#50;
Parent : Person? where value in People;
} where identity(Id);
People : Person*;
}
This is translated into the following T-SQL:
create schema [Tree];
go
create table [Tree].[People]
(
[Id] int not null identity,
[Name] nvarchar(50) not null,
[Parent] int null,
constraint [PK_People] primary key clustered ([Id]),
constraint [FK_People_Parent_Tree_People]
foreign key ([Parent]) references [Tree].[People] ([Id])
);
go
The M tip of the day: One-to-Many relationships
March 8, 2009 by Stefan
Sometimes relationships can be tricky. But in the fantastic M world they are not that difficult at all. Let’s say for example that you have a product domain containing a product and a product group , and when modeling this domain you want to define a relationship constraint between product and product group objects saying that a product only can exist in one product group. At the same time the product group should be able to have zero or more products. This can easily be modeled using a so called entity reference. Like this:
| module ProductDomain { type Product { Id: Integer32; Name : Text#50; ProductGroup : ProductGroup where value in ProductGroups; } where identity(Id); Products : Product*; type ProductGroup ProductGroups : ProductGroup*; |
This will translate into the following T-SQL
|
/…/ create table [ProductDomain].[ProductGroups] create table [ProductDomain].[Products] /…/ |
Five great information sources on MSchema
March 4, 2009 by StefanModeling with MSchema
March 2, 2009 by StefanI am, as many other developers I presume, in the early process of grasping what Oslo is all about, so what could be better than sharing that process (and mistakes I do) with others. ![]()
In this post I will retell a lightning talk I had a while ago at Dotway’s office in Stockholm.
Before having this Lightning talk I installed the Oslo SDK January 2009 CTP and SQL Server 2008, and of course I read the excellent documentation that comes along with the Oslo SDK.
So this step-by-step talk was about how to model a fracture of a simple CV domain using the MSchema and Ipad (Intellipad) and how to use the M tool chain to put the model in SQL Server. I deliberately kept the domain as simple as possible just to be able to show some of the basic steps involved in the modeling process.
Here it goes…
So, the first thing you need to do is to open up the text tool Ipad (Samples Enabled). You can do this either by running this in a command prompt: “C:\Program Files\Microsoft Oslo SDK 1.0\Bin\Intellipad\ipad.exe” /configuration:ipad-vs-samples.xaml, or even simpler by opening it from the start menu.
Save Untitled1 as CV.m (.m is the format for M source files). Notice how the mode was changed from Standard Mode into M Mode.
Everything you write in MSchema need to be inside a module, so add a module called CV:

A module controls visibility in the same way as CLR-namespaces do, however it also allocate storage, among other things. You may split up a module in different files, and a file may contain more than one module but a module cannot contain other modules. A module corresponds to a SQL Server database schema.
The CV domain has consultants (each with an id and a name field) so let’s define that by adding a Consultant type into your module, something like this:

The AutoNumber() above, which is used to set a default value, maps to “identity”in T-SQL and the identity(id) constraint maps to the primary key on that field.
Wouldn’t it be interesting to see the T-SQL that maps to our type?
In Ipad you have two different views that let you see a preview of the T-SQL that corresponds to your model. The first one called Repository T-SQL Preview displays T-SQL based on the Oslo Repository design patterns. The second one called Generic T-SQL Preview displays a simpler version of the T-SQL needed to create a database schema corresponding to your model. For the purpose of this tutorial use the Generic T-SQL Preview menu choice, which you find under the M Mode menu.
At the moment all that is displayed is the following comment:
![]()
So go ahead and add an extent called Consultants to your module and see what will happen:

This will produce the following in the T-SQL preview window:

As you can see the extent Consultants corresponds to the table called Consultants.
Now add another type to your module called Skill with the fields Id, Name and description, and an extent called Skills:

Once again you get instant feedback from the T-SQL preview window:

Now let’s say you want a many-to-many relationship between the Consultant and Skill types. One way in which you can accomplish this is by adding a new skills field in the type Consultant and assign it the type Skill. You will also need to add a membership constraint to the field like this:

This will be transformed into a new SQL junction table:

The same thing would have been accomplished by adding this where predicate to the Consultants extent:

Although not shown here, in MSchema you can also model many-to-many relationships as two one-to-many relationships.
With this in place you can define a couple instances of consultant using MGraph:

So how do you get the model into a SQL Server database?
The first step is to compile your CV.m file into an image file. You do this with the m compiler, m.exe
Open up a new command prompt and navigate to the folder containing your CV.m file. Run the following line:
“C:\Program Files\Microsoft Oslo SDK 1.0\Bin\m.exe” CV.m -p:image -t:TSQL10
If you look inside the folder you will now find a file called CV.mx. The next step is to generate a new database containing the database schema found in CV.mx. This is done with the tool called mx.exe. Run the following line in the command prompt:
“C:\Program Files\Microsoft Oslo SDK 1.0\Bin\mx.exe” -i:cv.mx -db:cvdb -c -ig -f –verbose
Switch to SQL Server Management Studio and check that a database called cvdb has been created and that it contains the three tables CV.Consultants, CV.Skills and CV.Consultants_Skills. The database should also contain the insert into statements that you created with MGraph.
Ok, that’s it for now!
Me
March 1, 2009 by StefanHi, my name is Stefan Severin and I’m a consultant at Dotway, a company specialized in .NET technologies. My own specialty is WCF, but I am interested in all sorts of backend technologies that come from Microsoft.
In this blog I’m going to write about Oslo which is Microsoft’s new modeling platform.