The March 2004 Community Technology Preview of Visual Studio 2005 has a schema editor for editing mapping files for use in ObjectSpaces. This editor is accessible from a Web project as a Mapping file or as a ObjectMappingFile in a Visual Basic project. You cannot add it from Project, Add New Item… in a C# project. There you will have to copy it from another project or add an existing item. Alternatively you can add an XML file and add the following content: <?xml version=”1.0″ standalone=”yes”?> Once opened you will get a pretty, graphical designer of your mapping file as in the picture below. The functionality of this editor is not as complete as that of the ObjectSpaces Mapper Utility that was distributed at the PDC for use with the PDC bits. It does, however, do some other neat stuff, to which I’ll get in a moment. The most important thing is that it will edit the new rsd and msd mapping files. From the PDC bits the schemas for these files has changed considerably. The osd schema is still the same (although I did have the impression that some extra attributes where available. Who’s to tell, as the schemas for the mapping files where never made available) and has an unchanged namespace. Some of the things that you will miss in the editor are: The editor consists of two panes. On the left side you have the area that edits both the osd and the msd mappings. The right side edits the relational schema. These two panes can be interchanged by the mini-scrollbar-like button in the Mapping Tool toolbar. Starting with the object schema you have a choice of importing an existing object schema, or create a new one. When a new schema is created it is stored inline inside the msd file. Importing an existing schema will be referenced as it was in the PDC Mapper Utility. This might be convenient for you if you plan to create ObjectSchema objects, where you will need an osd file (you cannot specify an msd file with an inlined schema. An exception will be thrown stating that the root element is not the correct one). You can add classes from either the Class View window or the Object Browser by dragging them to the pane. Adding them manually as new classes by right-clicking and selecting it from the context menu is another possibility. In this menu you will find two options: adding a new or existing class. For an existing class the fully qualified name needs to be provided. If found in the project or its references the class and its members are added. A new class will be added without any members. The relational schema can be created with the same options as the object schema. Dragging the desired tables and views from the Server Explorer or Data Connections window is the easiest way. You can do it manually as well. If you do drag them all related items, such as stored procedures, are also added to the schema under Unmappable Structures. You may want to remove these. After the object and relational schemas are ready, you can start building your mapping. In middle section of the editor you can add your mappings in the top half, right of where the classes in the object schema are shown. Clicking in the boxes right of the classes (not the members) a Map Candidates dropdown will appear. This holds the available tables and views. After selecting one from the list, you can map members to fields in the same way. Once you have all mappings in place and save the file, you should be ready to try loading your file into an ObjectMapping. The code is pretty simple: ObjectMapping map = new ObjectMapping(“mapping.msd”); If you get no ObjectManagerException on this object construction, you can compliment yourself on a job well done (so far). In newer builds the reverse engineering options for the object and relational schemas should be available (M3 milestone). There’s much more to explore in the mapper, but more on that in another entry. Make sure that you select all visual elements of the mapping editor and keep a close watch on the Properties window while you do so. Also, try to drag and drop elements on the panes or onto tree elements. You’ll be amazed what you encounter this way.
<m:MappingSchema
xmlns:m=”http://schemas.microsoft.com/mapping/2003/06/msd” >
</m:MappingSchema>
-
Recent Posts
Recent Comments
Archives
- September 2011
- July 2011
- June 2011
- April 2011
- November 2010
- October 2010
- July 2010
- June 2010
- October 2009
- August 2009
- July 2009
- June 2009
- May 2009
- March 2009
- February 2009
- January 2009
- November 2008
- October 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006
- February 2006
- January 2006
- December 2005
- November 2005
- October 2005
- September 2005
- August 2005
- July 2005
- June 2005
- May 2005
- April 2005
- March 2005
- February 2005
- January 2005
- December 2004
- November 2004
- October 2004
- September 2004
- August 2004
- July 2004
- June 2004
- May 2004
- April 2004
- March 2004
- February 2004
- January 2004
- December 2003
- November 2003
- October 2003
Categories
Meta