Home > Developing Using CodeFluent Entities > Creating Portable Models

Creating Portable Models


By portable models I mean a model that someone else can retrieve from the source server and build right away without having to edit it.

To do so the idea is to avoid writing hard-coded paths or server names in the model in order to keep it as portable as possible. CodeFluent Entities supports environment variables as well as relative paths, so use them whenever needed to achieve this goal.

For instance, the following line will fail on 64-bit machines, or configurations where CodeFluent Entities was installed somewhere else:

<cf:pattern path="C:\Program Files\SoftFluent\CodeFluent\Current\Patterns\SoftFluent.Localization.xml" step="Methods" />

Using an environment variable instead, makes the path used specific to the current machine or user:

<cf:pattern path="%CF_PATTERNS_PATH%\SoftFluent.Localization.xml" step="Methods" />

Note: CF_PATTERNS_PATH is part of several well-known environment variables recognized by the product. Other available ones are CF_CURRENT_PATH, CF_TEMPLATES_PATH, CF_DEFAULT_PERSISTENCE_SERVER, CF_BUILD_NUMBER.

Likewise, avoid writing connection strings in your model, because if another developer doesn’t have access to the pointed server, he won’t be able to build the model without editing it. Instead, CodeFluent Entities uses the CF_DEFAULT_PERSISTENCE_SERVER environment variable as the default server to connect to. Therefore, instead of hard-coding server names, set this environment variable to the desired server, then you might not even have to set a connection string in your model.

This last point was actually covered in this previous post: Default Persistence Server.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s