Thursday, June 9, 2011

SQL Server Compact Toolbox 2.2–Visual Guide of new features

After more that 32.000 downloads, version 2.2 of my SQL Server Compact Toolbox extension for Visual Studio 2010 is now available for download. This blog post is a visual guide to the new features included in this release, many suggested by users of the tool via the CodePlex issue tracker

Generate an Windows Phone DataContext (.cs) in the current project (beta feature)

image

This feature allows you to create a DataContext for use with Windows Phone “Mango” projects, based on an existing SQL Server Compact 3.5 database.

This will be a huge timesaver, and allows you to reuse the effort you may already have put in creating your database schema, including foreign keys and the required indexes. It will also save you much repetitive code, as the generated classes reflect your tables 1:1.

This technique even works with Northwind.sdf, despite object names with spaces. None of this is (of course) supported in any way by Microsoft.

image

Under the covers, I am using SQLMetal to generate a desktop DataContext class, and then this class is enhanced to work well in a Windows Phone project.

Advantages of this approach:
- Use desktop database tools for data population and schema design
- Saves time doing 1:1 mapping between database tables and DataContext classes
- DataContext classe and entity classes are partial and can be expanded
- Invalid DataContext constructors removed
- The generated DataContext contains Index definitions (which SqlMetal does not support, as this is a Windpows Phone extension)
- The generated DataContext contains the CreateIfNotExists method, that optionally extracts an included database (prepopulated with data) to Isolated Storage

If you also would like to include your desktop database with your XAP, the generated DataContext contains the code from this blog post and supports the procedure described in the blog post.

Please provide any feedback for this beta feature to the CodePlex issue tracker.

Add Description to tables and columns

image

On Database, Table and Column level, there is a new menu item: Edit Description, that allows you to enter a object description. The object description are stored in a table named __ExtendedProperties in the current database.

image

The description is then shown as a tooltip for the object:

image

In addition, you can reuse the data for documentation etc. (I am planning a documentation feature in a future release)

Options dialog for saving options from session to session

image

A new options dialog is available from the main toolbar:

image

SQL Editor improvements

The SQL Editor (again) allows you to display the results in a Grid, rather than text. This can be selected via the Options above. (Using grid will be slower and requires more memory). Also, a Save Script button has been added.

image

Other minor improvements

Latest scripting libraries included, with improvements to Db Diff and primary keys with multiple columns

Thanks to all Toolbox users for your continued encouragement and feedback!

No comments: