Add Schemas to a Domain
[This content is no longer valid. For the latest information on "M", "Quadrant", SQL Server Modeling Services, and the Repository, see the Model Citizen blog.]
This is the second step in the Getting Started with SQL Server Modeling CTP and Visual Studio 2010 tutorial. The preceding step is Create a Domain using "M". The following step is Deploy Domains to the Database.
In this task, you use “M” code to specify the database schema that stores the application data. This simple schema consists of the Dinner
and RSVP
types and corresponding extents, which represent tables in SQL Server. You also create a test Dinner
row.
Define Dinner and RSVP schemas by using “M”
In Solution Explorer, in the
MiniNerdDinner
project, right-click the Models folder, click Add, and then click New Item.In the Add New Item dialog box, on the Data tab, select “M” Model. Change the name to
Dinners.m
and click Add.In the Entity Data Model Wizard, select Default Model, and then click Finish.
In the
Dinners.m
window, replace the default text with the following “M” code.module MiniNerdDinner { type Dinner { Id : Integer32 => AutoNumber(); Title : Text(50); EventDate : DateTime; Description : Text(256); HostedBy : Text(30); ContactPhone : Text(20); Address : Text(50); Country : Text(30); Latitude : Single; Longitude : Single; } where identity(Id); Dinners : {Dinner*} { Dinner_1 { Title => ".NET Futures", EventDate => 2009-12-05, Description => "Come talk about cool things", HostedBy => "Kim Abercrombie", ContactPhone => "425-555-1212", Address => "One Microsoft Way, Redmond, WA 98052", Country => "USA", Latitude => 47.64312, Longitude => 122.130609 } } }
Build the project.
Add an
RSVPs.m
file to the project and initialize it with the following “M” code.Tip
When you created the
Dinners.m
file, the Entity Data Framework Wizard created a template model file,Model.m
, as well. In this step, you have a choice of repeating steps one through three to create a newRSVPs.m
file and then delete theModel.m
file, or you can rename theModel.m
file and skip creating a new one. Adding subsequent models by repeating steps one through three does not create additionalModel.m
files in your project.module MiniNerdDinner { export RSVP; export RSVPs; type RSVP { RsvpID : Integer32 => AutoNumber(); Dinner : Dinner; AttendeeName : Text(30); } where identity(RsvpID); RSVPs : {(RSVP where value.Dinner in Dinners)*} { { Dinner => Dinners.Dinner_1, AttendeeName => "John" } }; }
The project looks like the following:
See Also
Concepts
Getting Started with SQL Server Modeling CTP and Visual Studio 2010