Up Model code samples
DevForce 2010 Resource Center » Code samples » Model code samples » Set the generated model namespace

Set the generated model namespace

Last modified on May 04, 2011 11:37

This walkthrough explains how to change the generated namespace for the entity model from the default.


Problem

You want to set the generated namespace to a value different from the default namespace.

Solution

Set a fixed namespace name for the model generated by the DevForce Entity Framework Mapping tool.

When To Use It

When you want the namespace name to be other than the default namespace name of the project.

By default, the DevForce Entity Framework Mapping tool generates entity classes under the current namespace of the project that holds the EDMX.  In fact, if you change the project's default namespace, DevForce will regenerate your model with the revised namespace name.

Sometimes you want to fix the value of the model namespace name to something other than the project default namespace.

Do that by changing the "Custom Tool Namespace" property value on the DevForce T4 Template (.tt) file's Properties Window.

Example

You have an edmx named "ModelFirst.edmx". Accompanying it is a DevForce T4 Template (".tt" ) file called "ModelFirst.edmx.tt"

Highlight that TT file and open its Properties Window (Click F4  or Alt-Enter or use the context menu). The window should look something like this:

   TT File Properties Window - before setting namespace

Enter your new value

   Custom Tool Namespace after change

The DevForce Entity Framework Mapping tool immediately re-generates the entity classes under this namespace.

N.B.: The tool does not update the namespace names of your custom partial entity classes or of any other classes in the project because the tool never touches files other than the ones it generates. You'll have to update your custom classes manually.

Created by DevForce on September 27, 2010 10:54

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