SQL Server Compact Toolbox – Extension #12

Today’s post comes from Guest Blogger Erik Ejlskov Jensen, SQL Server Compact MVP, @ErikEJ

Toolbox for SQL Server Compact developers

If you use SQL Server Compact, Microsoft’s embedded database for devices, desktops and soon ASP.NET, this extension is for you.

It adds several features not found in Server Explorer Data Connections:

  • Support for both version 3.5 and 4.0 database files
  • Script tables, including data
  • Script entire schema, optionally with data, both of SQL Server Compact and SQL Server 2005 or later databases
  • Import to SQL Server Compact from a SQL Server 2005/2008 database or a CSV file
  • Basic, free form query execution, with Excel friendly output
  • Parse SQL scripts
  • Display graphical estimated query plan
  • Generate detailed DGML files for visualizing table columns and relationships (requires VS 2010 Premium or higher to view)
  • Create and manage SQL Server Merge Replication subscriptions

clip_image002

To install

http://visualstudiogallery.msdn.microsoft.com/en-us/0e313dfd-be80-4afb-b5e9-6e74d369f7a1

To use

To start using the add-in, go to Tools, and select SQL Server Compact Toolbox:

clip_image004

The add-in will list any version 3.5 database connections, which you have defined in Server Explorer. For 4.0 (which is currently not supported in Server Explorer, but will be so in VS 2010 SP1), you can add a connection from the context menu (or even create an empty 4.0 database file):

clip_image005

To refresh the listed connections, click the refresh button on the add-in toolbar.

Scripting an entire database

To create a SQL script file with all object definitions and data in your SQL Server Compact database (for documentation, backup or migration use), select “Script database schema and data” from the context menu:

clip_image006

Viewing estimated execution plan

To find out if you are missing indexes in your database, you can examine the graphical estimated query plan.

clip_image007

With the SQL editor open, press Estimated Plan:

clip_image008

It looks like an index is used here, which is a “good thing”.

Displaying a graphical view of your database

From the database context menu, select “Create Database Graph (DGML)”

clip_image009

This will allow you to explore an interactive graph of your database tables, relationships, and columns:

clip_image011

More information

You can submit feedback/patches, request features and browse/download the source code at the CodePlex site: http://sqlcetoolbox.codeplex.com – and keep up to date with the latest SQL Server Compact news on my blog: Everything SQL Server Compact

Have you written an extension? Want to see it featured here? Let me know!

Solution Explorer Tools (When to Sync to Current File) – Extension #11

Control when Solution Explorer syncs to the current file

I’ve given many talks on Visual Studio, and one of the most popular questions is about controlling when Solution Explorer syncs to the current item. This extension is the best one I’ve seen in providing this functionality.

To Install

You can find the Solution Explorer Tools extension at http://visualstudiogallery.msdn.microsoft.com/en-us/ef4ac3e9-d056-4383-8ca2-11721bd879b4

To Use

First, you must disable the “Track Active Item in Solution Explorer” in Tools – Options – Projects and Solutions – General page.

Track Active Item in Solution Explorer option disabled

Now the fun can begin.

On the Solution Explorer, you’ll see 3 new icons.

New commands on Solution Explorer

Starting right from left:

  1. Sync Item – sync’s the Solution Explorer to whatever document is open (or the last active item if a tool window is in the file tab channel).
  2. Collapse All – recursively collapses everything in the solution explorer
  3. Collapse to Item – this combines the previous commands. This will sync to the currently opened item and collapse everything else.

You can also bind keyboard shortcuts to each of these commands via the Tools – Options – Keyboard page:

  • Project.SyncItem
  • Project.CollapseItem
  • Project.CollapseToItem

Some keyboard shortcut suggestions are to bind Project.CollapseToItem to Ctrl+Alt+semicolon, since it is right next to the Ctrl+Alt+L keystroke that opens the Solution Explorer. If you really like this feature and want it on all the time, you could bind it to Ctrl+Alt+L, overriding the standard Open Solution Explorer commands, so the Solution Explorer will always open and collapse to the current item.

Just double-check what your keyboard shortcuts are bound to, as your settings may be different than mine.

More information

Check out the extension’s gallery page at http://tinyurl.com/solexp

Emacs Commands – Extension #10

Use your Emacs commands once again!

If you have opened the Tools – Options – Keyboard page, looking for the “Emacs” keybindings, but only found disappointment instead.

Emacs in keyboard scheme options

This extension is for you!

To Install

http://visualstudiogallery.msdn.microsoft.com/en-us/09dc58c4-6f47-413a-9176-742be7463f92

To Use

In order to finish the installation, you must open/create a project. This will prompt you for elevated permissions to finish installing the Emacs.vsk file (the emacs keyboard shortcut file) to the Visual Studio IDE folder located under Program Files (hence the elevated permissions since you need to be an admin to get in here on the file system).

image

Once a project is opened, you’ll see the Emacs item in the Tools – Options – Keyboard scheme dropdown.

Emacs in keyboard scheme options

Quick Primer on Emacs

For those new to Emacs, here’s a quick example how it works in Visual Studio. (This is the way Emacs was explained to me 10 years ago.)

The “big” key is the Alt key.

The “small” key is the Ctrl key.

If you want to navigate forward, just letter by letter, you press Ctrl+F (small Forward). If you want to navigate backward, just letter by letter, you press Ctrl+B (small Backward).

If you want to navigate forward, word by word, you press Alt+F (big Forward). If you want to navigate backward, just letter by letter, you press Alt+B (big Backward).

My favorite part of using Emacs was the ability to move up and down without having to reach for the arrow keys (Ctrl+U, Ctrl+D).

Uninstall

I’m calling out the uninstall because it looks like when you disable or even uninstall the extension, the Emacs option still remains selected in the Tools Options Keyboard list. You must go back to Tools Options Keyboard and select the “(Default)” keybindings.

Selecting Default on the keyboard mapping scheme

Since it required admin rights to add it, you’ll need admin rights to remove it. And i’m guessing if the extension waits until a project is opened to prompt you for these permissions, there isn’t a place for the extension to prompt you to remove the .vsk file. (you can’t be prompted the next time you open a project because the extension is gone.) But that’s just my guess.

If you forget this step, you’ll notice a great many things not working, like Ctrl+F. Since in the Emacs keybindings that’s bound to a command that no longer exists in VS, you’ll won’t see Quick Find dialog. Simply go to Tools Options Keyboard and select Default, and VS will be right as rain.

You can always manually delete the Emacs.vsk file yourself at your own risk.

More Information

You can find more information on all the Emacs keyboard shortcuts supported by the extension at the bottom of this post.

http://visualstudiogallery.msdn.microsoft.com/en-us/09dc58c4-6f47-413a-9176-742be7463f92

VS File Explorer – Extension #9

Get a Windows Explorer experience within the IDE!

My series continues with the VS File Explorer. I call this extension out because of its tag line:

The Visual Studio File Explorer Add-in (sexy name we know, but hey, it’s self documenting)

Gotta love self-documenting Add-in names. Rock on.

Seriously, it was the Shell Extension within Visual Studio experience that grabbed my attention. See below.

To Install

The VS File Explorer extension can be found in the Visual Studio Gallery at http://visualstudiogallery.msdn.microsoft.com/en-us/7193af78-b06e-48dd-8994-9deb2bfa1959

To Use

The tool can be found at View – Other Windows – Mindscape File Explorer.

View - Other Windows - Mindscape File Explorer

This will open a tool window that has a Windows Explorer look-and-feel.

But a Windows Explorer in itself isn’t exciting. There’s some additional functionality that’s worth calling out.

Maybe there’s a feature here that will help improve your productivity.

Shell Extensions within Visual Studio

Let’s say I have a shell extension like TortoiseSVN. (Tortoise doesn’t have a GUI per se. It inserts itself into Windows Explorer.) Using VS File Explorer, you can now see TortoiseSVN within Visual Studio.

TortoiseSVN shell extensions within VS

Just a heads up, for you 64-bit users, you might want to read this thread. (You need the 32-bit version of Tortoise to run within VS).

Command Prompt Here

This command will open a command prompt, regardless whether the selection is in the right-pane or left-pane.

Command Prompt Here icon

But note, this by default will be your standard command shell, cmd.exe, and not the Visual Studio Command Prompt. There is an option to customize what is run when you press this button.

Home

Home icon

I had to ask Mindscape about this one.

The “Home” button will change the root folder to whatever the “Default Root Folder” is in the Options dialog.

However, seems that there’s a bug that you have to change the “Default Root Folder” to something other than the installed default in order for the “Home” button to do something. Otherwise, trying to click “Home” will cause Visual Studio to stare at you like an old dog in obedience class looking at you as if you actually expect him to fetch that ball.

Snap to Current Solution

At first glance, I thought “snap” would take the highlighted project/code and add it to the current solution. Mais non!

“Snap To Current Solution” changes the current root folder to the current solution folder. As shown below, my Code default root folder becomes ConsoleApplication1

example of "Snap To Current Solution"

Change Root Folder

Change Root Folder icon

Not to be confused with the “Default Root Folder” setting, this command just changes the current root folder view in the left-pane. It doesn’t change the “Default Root Folder”, the folder that “Home” will go to.

Options

Options icon

Just as it sounds, here be anthropomorphic dragons, i mean here is where all the settings live for the VS File Explorer.

There are four settings here

  • Default Root Folder – What the “Home” button will take you to
  • Excluded Files – the files the VS File Explorer should not show
  • Open In Visual Studio – what do you want to happen when you double-click or press “Open” on a .sln file? Do you want VS to open it, or do you want it opened by its default application.
  • Command Prompt – here’s where you can change the .exe that is executed. For example, I changed mine to \Windows\System32\notepad.exe. Now when I click the command prompt icon, I get notepad. Might be able to do some interesting things here.

Know of an Extension you’d like to see here. Let me know!

Power Commands for Visual Studio 2010 – Extension #8

I’m way behind in my extension series. Relocation + New Job + Work Travel, it’s been a crazy year!

The Power Commands for Visual Studio are back! The Power Commands were an extremely popular add-in for Visual Studio 2008, giving you even more options for your IDE.

To Install

The Power Commands extension can be found on the Visual Studio Gallery at http://visualstudiogallery.msdn.microsoft.com/en-us/e5f41ad9-4edc-4912-bca3-91147db95b99

Please see this post on how to install extensions if you need additional help.

To Use

The Power Command options can be found all throughout the IDE. To help you discover what all the Power Commands do, I’m going to review each option below.

Pay close attention to the Choose Which Commands You Want To Use section. All commands are enabled by default, but if there are a few you never will use, or don’t want to use, you can disable them in Tools Options.

Format Document On Save

Ctrl+K, Ctrl+D is the keyboard shortcut to format the current document (found under Edit – Advanced – Format Document). This is very useful to know when you cut and paste code from a website or somewhere else that causes the formatting to go crazy.

But maybe you don’t want to think about keyboard shortcuts. Or maybe you just one less thing to worry about as you save the document.

You must enable the “Format Document On Save” option at the Tools – Options – PowerCommands – General page.

Now whenever you save a document, and formatting that’s off, as shown below

extra whitespace on line

will be corrected automatically.

corrected whitespace

Remove And Sort Usings On Save

Alas, this is only for C#. On the C# context menu, there are the “Organize Usings” commands.

Remove and Sort Usings on context menu

These options are great when you want to clean up your using statements at the top of the file, by removing any using statements not actually being used and also by sorting them in alphabetical order.

non-sorted using statements

Talk about a huge timesaver!

But let’s save even more time by having the editor do this automatically whenever you press save. You can find the option to enable this feature at Tools – Options – PowerCommands – General page.

Remove and Sort Usings

Let’s take this awesome one step further. Instead of removing unused using statements at the file level, let’s remove and sort them at the project level!

Remove and Sort Usings on context menu

As illustrated above, the command “Remove and Sort Usings” can be found on the Solution Explorer context menu at both the Solution level and at the individual project levels.

Clear All Panes

In the Output Window, you can have multiple panes, the most common being Build and Debug. There’s a “Clear All” button (indicated below) that will just clear the current output window pane.

If you want to clear all output sub-windows at once, press the “Clear All Panes” button located just to the right of the “Show Output From” drop down.

Clear All Panes on Output Window

Copy Path

No more having to open a file to copy its file path from the file tab.

This command copies the full path of the currently-selected item to the clipboard. It works with the solution node, a project node, any project item node, and any folder.

Copy Path on Solution Explorer context menu

Email Code Snippet

Exactly as it sounds.

Select some code in the editor, then right-click and select “Email CodeSnippet.”

Email CodeSnippet on context menu

And it also fills out the subject for you.

To: You
From: Me
Subject: CodeSnippet from Program.cs

Insert Guid Attribute

To add a GUID attribute to a class, right-click anywhere within the class and select “Insert Guid Attribute”, and those few extra keystrokes are done for you.

System.Runtime.InteropServices.GuidAttribute(...)

Show All Files

The only thing better than one “Show All Files” button is two “Show All Files” buttons! The one on the left is for the current project, but the one on the right is for the entire solution.

current project versus entire solution icons

Undo Close

ROCK ON!

How many of you like me close something only to realize in that instant that you wanted to look at something again. This command is for us!

To reopen the most-recently closed document, go to Edit – Undo Close. Keyboard shortcut is Ctrl+Shift+Z. It’ll even return the cursor to its last known position.

But it gets better…

Want to see all of your most-recently closed documents? Go to View – Other Windows – Undo Close Window.

Undo Close tool window

Collapse Projects

If you want to collapse everything under a project node, including any sub-nodes (this being the key difference from the standard Windows behavior), right-click and select “Collapse Project” from the Solution Explorer context menu.

Thus a project like this

fully expanded node in Solution Explorer

will collapse everything, including the Properties and the Resources.resx nodes, as shown below. (I expanded the XAMLVisualizer node for illustration purposes).

collapsed sub-nodes in Solution Explorer

This command works for solutions, projects, and solution folders.

Copy Class / Paste Class

On the Solution Explorer, select a project item (usually a class file) you want to copy. Right-click and select “copy class.” Now navigate to the project node and right-click to see the “Paste Class” command.

a copied class in solution explorer

It will also rename the class to avoid compiler errors.

Copy References / Past References

This command allows you to copy all your references for a project, then paste them into another project. No Add Reference Dialog needed!

Copy References on Solution Explorer

You can also do this across multiple instances of the IDE.

For C# projects, the command is found on the references node. For VB and ASP.NET projects, it is found on the project node.

Copy As Project Reference

Just like in the previous command, why use the Add Reference Dialog if you don’t have to. The “Copy As Project Reference” command found on the Solution Explorer context menu will allow you to copy a project (from its project node) and then paste it into another project node as a project reference.

Copy as Project Reference example

Edit Project File

One of my more popular tips, especially for those who work on MSBuild project files, is the ability to quick edit your project files without having to shut down Visual Studio and open up notepad. The tip was to Unload Project and Edit Project (all via Solution Explorer context menu).

The “Edit Project File” combines these two commands for you, unloading the project and opening the file in the editor for you.

Edit Project File in editor context menu

You’ll still need to Reload the project file when you’re done. The command is found by right-clicking on the project node.

Open Containing Folder

Similar to the command found on the File Tabs and in the Solution Explorer for a node, this command opens the containing folder for an item in the Solution Explorer.

Open Containing Folder on Solution Explorer context menu

Open Command Prompt

For The Win!

Open a Visual Studio command prompt directly from the Solution Explorer! I say a “Visual Studio” command prompt, and not just a command prompt, because this one has the Environment Variable set to know where devenv.exe lives. So no more having to be frustrated with “devenv is not recognized as an internal or external command….”

Open Command Prompt via Solution Explorer

Unload Projects / Reload Projects

Similar to the built-in command for unloading a project, the Unload Projects command (found on the Solution Explorer context menu for a project node) will unload all the projects in a solution. Useful for editing multiple MSBuild files.

Unload multiple projects example

And to reload all your projects, there’s the Reload Projects command.

Extract Constant

Found under the Refactor menu, the Extract Constant will do exactly what it sounds like it does. It will create a constant based on the selected text. For example, consider the Console.WriteLine() parameter I have below:

Extract Constant on context menu

Selecting this text, I can specify “Extract Constant”. It will bring up a dialog to allow me to specify scope and give the new string a name.

Extract Constant dialog box

Pressing enter creates the string, the WhoDat constant in this example.

image

Clear Recent File List

No longer having to go to the registry to clean up your recent files list. The “Clear Recent File List” command will do that for you. Go to File – Recent Files – Clear Recent File list.

Clear Recent File List on File - Recent Files menu

This will bring up the Clear Recent File List dialog for you to pick and choose what to delete.

Clear List dialog box

Wow! I have a lot of recent files!

Clear Recent Project List

Similar to the above tip, the Clear Recent Project list will allow you to clean up your recent project list. It is found at File – Recent Projects and Solutions – Clear Recent Project List.

Clear Recent Project List dialog box

Close All

Found on the File Tab context menu, this command will close all open documents.

Close All on File Tab Context menu

Choose which commands you want to use!

By default, all the power commands are enabled. To only enable those you’re going to use, you can go to Tools – Options – PowerCommands.

Tools - Options - Power Commands - Commands

And on the Commands page, you’ll find the full list of all the commands available with this extension.

All possible PowerCommands options to enable/disable

Collapse Selection in Solution Explorer – Extension #7

Recursively Collapse Nodes in the Solution Explorer!

The Visual Studio IDE team has heard a lot of feedback asking for a way to recursively collapse nodes in the solution explorer. For example, right out of the box, when you collapse a node in Solution Explorer, it only collapse just that node. But, what if you want to collapse all sub-nodes at the same time? Then you’ll want to install the Collapse Selection in Solution Explorer extension.

To Install

The extension can be found on the Visual Studio Gallery at http://visualstudiogallery.msdn.microsoft.com/en-us/cb0ec47d-05a4-40a7-ba39-9a2da6492f1c

To Use

Once installed, you’ll see a new button in the Solution Explorer toolbar. This button will recursively collapse the selected node or nodes (note: you can multi-select different nodes to recursively collapse at the same time.)

node with lots of sub nodes expanded

Now when we collapse and expand the TestApp project, we’ll see the sub-nodes also collapsed.

node with sub nodes collapsed

And the keyboard shortcut is Ctrl+Alt+Num(-)

More Info

You can read more about this extension on the VS IDE team’s blog. http://blogs.msdn.com/visualstudio/archive/2010/05/13/announcing-collapse-selection-in-solution-explorer-extension.aspx

Find Results Windows Tweak – Extension #6

Increase the Readability of your Find in Files results!

One of the first tips I always demo in my talks is how to edit the registry to make the Find Results Window more readable. Many thanks to Robert MacLean who has put together this extension that provides you with a dialog box for modifying the Find in Files results.

To Install

The extension can be found on the VS Gallery at http://visualstudiogallery.msdn.microsoft.com/en-us/7a412596-d9e4-462e-9eed-e00a92024130

It is also hosted on CodePlex at http://findresultstweak.codeplex.com/

To Use

Go to Tools – Find Results Tweak to open the dialog box which display an interactive preview. By default, the tool provides you with some recommended settings

recommended format string for customizing Find Results

which will remove the file path (the most important tweak you can make, IMO) and provide the (line, column) information where the result was found, as shown below

No more file path in search results

To Customize

If you want the full list of customizations, you can check out my old blog post at http://blogs.msdn.com/saraford/archive/2008/11/24/did-you-know-you-can-customize-how-search-results-are-displayed-in-the-find-results-window-363.aspx

To get back to the default VS behavior, you can check Use default Visual Studio formatting. Or, if you are comfortable modifying the registry, you can manually remove that specific registry key as indicated in the link above.

XAML IntelliSense – Extension #5

Get your new IntelliSense features in the XAML Editor!

If you’ve grown accustomed to the new Pascal Casing and List filtering features in IntelliSense, the Visual Studio 2010 XAML Editor IntelliSense extension will give you these features plus more in the XAML editor.

To Install

The project is hosted at http://karlshifflett.wordpress.com/2010/03/21/visual-studio-2010-xaml-editor-intellisense-presenter-extension/

To Use

Start typing in any XAML editor to bring up IntelliSense. Now at first, you may not see a difference. But say you type in “Button”, you’ll see the Pascal Case narrowing (provided you left that option enabled by default, as circled below).

pascal casing in XAML Editor

You can also specify matching based on filter type. For example, say you didn’t want to see any namespaces, you can disable it.

narrowing list based by filter

For more information

Check out the blog post for this extension: http://karlshifflett.wordpress.com/2010/03/21/visual-studio-2010-xaml-editor-intellisense-presenter-extension/

Editor Guidelines UI – Extension #4

Add Guidelines to your code!

Over 5 years ago, I wrote my very first tip about Visual Studio on Guidelines, a hidden feature to enable visual column indicators to the editor.

Finally, through this extension, we have a way to set and customize guidelines through the UI without manually changing registry keys.

Editor showing a guideline and its UI

The registry key will work on versions 2002, 2003, 2005, and 2008. However, the registry key will not work on VS 2010 without this extension.

To Install

This write-up is for two extensions:

  • Editor Guidelines – This extension puts the guidelines feature back
  • Editor Guidelines UI – This extension extends the Editor Guidelines extension such that UI can be used instead of manually editing the registry.

Please see my post How To Install Visual Studio Extensions.

To Use

If you’re just using the first extension, you’ll have to manually edit the registry yourself, so use at own risk. The key is the same as previous versions, which is [HKCU]\Software\Microsoft\VisualStudio\10.0\Text Editor. You’ll create a new REG_SZ string with for example “RGB(0,255,0) 100” to set a green guideline on column 100.

If you’re using the second extension, things are a lot simpler.

Just right-click wherever you wish to place the guideline, and from the context menu, select Add guideline. To remove, put your cursor on the column where you wish to remove the guideline, and right-click, and select Remove guideline.

To Customize

From the same context menu, you can select Guideline Color and get the standard color palette control.

standard color palette

Apologies for the delayed post. I was giving talks on Visual Studio and some of the extensions in Europe last week, but never had a chance to blog about them!

Visual Studio Tip of the Day Start Page – Extension #3

I have waited 6 years to write this blog post. We did it Sean! We did it! =D

Get Visual Studio Tips Delivered Straight to your Start Page!

The Visual Studio Tip of the Day Start Page is an extension that allows you to get the latest Visual Studio 2010 Tips inside your IDE.

Visual studio Tip of the Day Extension

For those not familiar with the Tip of the Day, I started a 382 tip series years ago on Visual Studio 2008, which Zain has graciously continued for Visual Studio 2010. It’s quite an honor to watch someone continue on with your work.

To Install

Please see my post How To Install Visual Studio Extensions. The extension name is Visual Studio Tip of the Day Start Page.

Extension Manager showing Tip of Day Extension

To Use

First, you’ll need to tell Visual Studio to use the customized Start Page. You do this by going to Tools – Options – Environment – Startup. Then under the Customize Start Page, select [Installed Extension] Visual Studio Tip of the Day Start Page, as shown in the image below.

Tools Options Start Page customization

To Customize

There’s nothing really to customize here beyond what’s already been shown in this post. And, the UI is pretty straight forward how to read the individual tips.

Having said that, Zain has slightly more info about how to get out of trouble if an extension starts behaving badly at http://blogs.msdn.com/zainnab/archive/2010/03/23/announcing-the-visual-studio-tip-of-the-day-extension.aspx

Enjoy!