Up Refine in the EDM Designer
Model » Create the entity data model » Refine in the EDM Designer » DevForce EDM Designer extension

DevForce EDM Designer extension

Last modified on October 31, 2012 11:07

The EDM Designer only collects the information it needs for Entity Framework's native code generator. DevForce needs more information in order to generate its own entity classes. The DevForce EDM Designer extension adds features to the base EDM Designer that help the developer provide that extra information.


Extension installed

From the Visual Studio menu pick Tools | Extension Manager ... and scroll through the Extension Manager dialog until you see:

extensions.JPG
 
The DevForce 2012 EDM Designer extension is installed with DevForce.  

If you don't see this extension, there are several possible reasons:

  1. DevForce is not installed.  Since you're reading this that's probably unlikely, but just as with ensuring your printer is plugged in, needs to be mentioned.
  2. The extension was not installed for your user account.  The extension is installed per user:  see here for information on how to install the extension.

The extension changes the EDM Designer in two ways:

  1. It adds new DevForce properties to the “Properties” panel.
  2. It writes the property values into the conceptual model section of EDMX file as custom “annotations”.

Once the extension is installed and enabled, when you open an EDMX file you'll see a message like the following in the "DevForce" pane of the output window:

dfpane.JPG

Note that the extension will not load or process a model in a .NET 4.0 project.  You must re-target the project to .NET 4.5 in order to use the DevForce 2012 EDM Designer Extension. 

DevForce extension properties

This screenshot shows the EDM Designer displaying information about an entity property. 

design-entity-properties

The CompanyName property of the Customer entity has been selected in the diagram on the left. The Properties window on the right displays the EDM object definition properties of that CompanyName property, sorted by category.

In the middle of the Properties window is a new category, outlined in yellow, labeled “DevForce Code Generation”. This category was added by the DevForce EDM Extension. The properties in this category govern code generation of the CompanyName property.

The “Display Name” property is outlined in red with a value of “Company Name”. The developer is telling DevForce to add a .NET DisplayAttribute to the Customer’s CompanyName property when it generates the entity class code. 

The DisplayAttribute is a standard .NET UI hint; a UI control could discover that attribute and create a label with the words “Company Name” next to a TextBox. Many developers like to decorate their entities with such UI hints.

The DevForce EDM Extension writes this advice as an annotation to the CSDL section in the EDMX file. The CSDL definition of the CompanyName property looks like this:

XML
<Property Name="CompanyName" Type="String" Nullable="false" MaxLength="40"
          Unicode="true" FixedLength="false"
          ib10:DisplayName="Company Name" />

The attribute ib10:DisplayName is the DevForce annotation. After code generation the property looks like something like this:

C#
[Display(Name="Company Name", AutoGenerateField=true)]
public string CompanyName {...}
VB
<Display(Name:="Company Name", AutoGenerateField:=True)>
Public ReadOnly Property CompanyName() As String
 ...
End Property

Controlling code generation

DevForce Code Generation sections adorn every level of the CSDL specification. At the top level are properties to control code generation for the model as a whole:

properties.gif
 

Disabling DevForce code generation

There are two ways to enable or disable DevForce code generation for the entity models.

On a per-EDMX basis
You can switch between the DevForce code generator and the Entity Framework default generator for a specific entity model by setting the "DevForce Enabled" field on the EDMX property sheet:

enabled-false.gif

Globally for all of Visual Studio
You can enable or disable the DevForce extension itself from within the Visual Studio Extension Manager. Disabling the extension both removes the DevForce properties from the designer and disables DevForce code generation.


Tags:
Created by DevForce on February 25, 2011 15:06

This wiki is licensed under a Creative Commons 2.0 license. XWiki Enterprise 3.2 - Documentation. Copyright © 2020 IdeaBlade