Last summer, the senior developer on the Entity Designer team (Mike Kaufman) wrote a series of blog posts over on the ADO.NET team blog about how the designer uses the public APIs found in System.Data.Entity.Design.dll to do its model generation and code generation. He writes about the file formats used by the designer and the runtime, explains how EdmGen.exe uses these same APIs and talks about a project that he has on Code Gallery (EdmGen2) that is able to read and write EDMX files.
These are worth a read if you haven't seen them yet.
- Part 1 : Discussion on the file formats
- Part 2 : Model and code generation
- Part 3 : Validation
- Part 4 : Details on Mike's comand-line tool, EdmGen2
I have heard quite a few folks ask questions about how to use their keyboard more when using the Entity Designer. Many people can be more productive if they are able to use more of the keyboard (reduce mouse clicks). Fortunately, Visual Studio has ways to make keyboarding easier. In addition, the Entity Designer has its own built-in keyboarding support. Finally, the DSL Toolkit (the component that provides the boxes-and-lines Entity canvas) also has built-in keyboarding support.
Let's start with the DSL Toolkit. This component has a number of nice keyboarding options discussed by Garethj over on his blog. These keyboard shortcuts can be used when the Entity canvas is currently selected. I will make note of one in particular which is the INS key. If you select either the "Scalar Properties" compartment header, or a Property itself and hit the INS key, it will add a new Property to the Entity.
Next, let's cover VS keyboarding. Each menu item in every Entity Designer context menu is treated as a Visual Studio "command" and you can assign your own keyboard shortcut to it. Just click on the Tools menu, then Options. Under Environment, choose Keyboard. Scroll down the list in the middle until you see "OtherContextMenus.MicrosoftDataEntityDesignContext". Here you will see the list of commands that you can create keyboard shortcuts to. Let's map some keystrokes for creating a new entity and a new scalar property.
- Select OtherContextMenus.MicrosoftDataEntityDesignContext.Add.Entity
- Place your cursor into the "Press shortcut keys" text box
- Type, Ctrl-E twice
- Click Assign
- Select OtherContextMenus.MicrosoftDataEntityDesignContext.Add.ScalarProperty
- Place your cursor into the "Press shortcut keys" text box
- Type, Ctrl-E then Ctrl-P
- Click Assign
Now, open up a blank EDMX model. Type Ctrl-E, Ctrl-E and you should see the New Entity dialog. Type the Enter key to accept. Now, type ">" to move into the shape (using hints from Gareth's post above). Type Ctrl-E, Ctrl-P to add a new scalar property. You can expand on this, defining the keyboard shortcuts that make the most sense to you and that help you be productive.
Finally, the Entity Designer has some custom keyboarding defined in the Mapping Details window. To try this out, open an EDMX file that has a number of entities and mappings (or quickly reverse engineer a model from your database). Use this sequence to change focus to the Mapping Details window:
- Type the Home key
- Type the Tab key to move through the entities until you find the one you want to edit mappings for
- Type the Context Menu key, then type "M" to use the keyboard accelerator to show the Mapping Details window (if you keyboard doesn't have the special context menu key, then you can use the technique above to create a new shortcut for that command)
Now that the Mapping Details window is shown, hitting Tab will switch between the main window area and the toolbar on the left:
- If you have the toolbar highlighted, you can use the arrow keys to move between the buttons and the Enter or Space key to select one
- If you are in the main window area
- Use your arrow keys to move up and down the rows, or right and left across the columns
- If you have a cell selected that has a drop down list, hit Alt-[Down Arrow] to drop down the list
- Once a list is show, use the arrow keys to scroll up and down, Enter to select or Esc to cancel
Happy keyboarding!
Starting a new blog today, hoping to spend some time talking about Entity Framework Tooling and other topics.