views:

234

answers:

1

Does anyonw know how to extend, i.e., add funcionalities to the Entity Designer in Visual Studio?

For instance, I want to right click a property of an entity on the designer and have a new option on the context-menu that allows me to do any stuff I want.

+1  A: 

The Entity Designer in VS 2008 SP1 doesn't have many extensibility hooks. What you could do is leverage the Visual Studio extensibility (VSIP, now known as VSX):

  1. Add in your own context menu
  2. Use IVsMonitorSelection to get the current selection, from which you can get ISelectionContainer.
  3. If the user has selected the diagram surface, you can then cast ISelectionContainer as DiagramDocView. This is part of 'DSL', which is the framework that the Entity Designer uses for its designer surface.
  4. From here you can do lots of things within the DiagramDocView. DiagramDocView.CurrentDiagram will give you the Diagram object. You can call Diagram.NestedChildShapes to get all shapes in the diagram. To make changes to the diagram, you will have to create a DSL transaction and perform your edits to the shapes in the transaction. This is simply another level above the Entity Designer and everything will be handled correctly:

    using (Transaction tx = store.TransactionManager.BeginTransaction(txText))
    {
       // do something, such as creating an EntityTypeShape;
       tx.Commit();
    }
    

The Entity Designer in VS 2010 will have a lot more extensibility hooks to allow you to influence the model through the property window or through the wizard. New extensibility work in the new 'Model First' feature will basically allow you to generate anything from a model within Visual Studio in a composable way.

Adi Unnithan