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 November 06, 2012 12:24

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:

designer-extension.gif
 
The DevForce EDM Designer extension (or DevForce 2010 EDM Designer Extension for .NET 4.0 in Visual Studio 2012) was 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.  If your Windows account is a non-administrative account, this is highly likely.  The DevForce installation requires an administrative account, and will have installed the extension for that account only.  See here for information on how to install the extension for your version of Visual Studio.

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”.

Annotations are the approved way to extend the CSDL according to the specification.
"Annotations allow applications to embed application-specific or vendor-specific information into CSDL. The format does not specify how to process these custom-defined structures or how to distinguish structures from multiple vendors or layers. Parsers of the CSDL MAY ignore Annotations that are not expected or not understood."


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.

designer-extension.gif

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 © 2015 IdeaBlade