CodeFluent Entities Documentation
CodeFluent Variables Script
Send comments on this topic.
CodeFluent Entities > Development Tools > CodeFluent Variables Script

Glossary Item Box

Among tools installed with CodeFluent Entities, there's a batch file named cfvars.bat which enables users to easily set some environment variables that can ease working with CodeFluent Entities.

By default four variables are defined:

  1. CF_CURRENT_PATH: corresponding to the installation folder,
  2. CF_TEMPLATES_PATH: corresponding to the Templates folder installed in the installation folder,
  3. CF_PATTERNS_PATH: corresponding to the Patterns folder installed in the installation folder,
  4. CF_BUILD_NUMBER: corresponding to the current build number.

Even though optional, those variables get very handy in team developments. By using those environment variables in the model, even if developers have a different installation directory they'll be able to share the same model.

Note: In builds upper the 40505, the cfvars.bat file is not shipped anymore. The CF_CURRENT_PATH, CF_TEMPLATES_PATH, and CF_PATTERNS_PATH are defined at runtime if they aren't set. Else the already configured value is used.
Example of producers using environment variables Copy Code
<cf:project xmlns:cf="http://www.softfluent.com/codefluent/2005/1"
            defaultNamespace="Sample"
            defaultConnectionString="server=(local);database={0};Integrated Security=true">
  <cf:import path="%CF_PATTERNS_PATH%\SoftFluent.Localization.xml" runTemplate="true" step="Methods"/>
(...) 
  <!-- Produces the services configuration from the server configuration templates -->
  <cf:producer typeName="CodeFluent.Producers.CodeDom.TemplateProducer, CodeFluent.Producers.CodeDom">
    <cf:configuration sourceDirectory="%CF_TEMPLATES_PATH%\ServiceModel\Server"
                      targetDirectory="..\{0}"
                      outputEncoding="iso-8859-1"
                      compile="false"/>
  </cf:producer>
 
  <!-- Produces the client configuration from the client configuration templates -->
  <cf:producer typeName="CodeFluent.Producers.CodeDom.TemplateProducer, CodeFluent.Producers.CodeDom">
    <cf:configuration sourceDirectory="%CF_TEMPLATES_PATH%\ServiceModel\Client"
                      targetDirectory="..\{0}.WinFormApp"
                      outputEncoding="iso-8859-1"
                      compile="false"/>
  </cf:producer>  
</cf:project>

CF_DEFAULT_PERSISTENCE_SERVER

Another interesting possible environment variable is the CF_DEFAULT_PERSISTENCE_SERVER. Although not in the cfvars.bat by default, it's a very convenient variable which allows developers to free themselves from defining a connection string in their models.

By default CodeFluent Entities uses this connection string (where defaultNamespace is the default namespace of your project):

Default Connection String Copy Code
Application Name=[DefaultNamespace];server=[PersistenceServer];database=[DefaultNamespace];Integrated Security=true

If the CF_DEFAULT_PERSISTENCE_SERVER environment variable is set, it is the value used as [PersistenceServer]. If ever this value isn't specified, the value used is: 127.0.0.1

Using this variable instead of explicitly declaring a connection string in the model allows team members to share the same model without having them to continually modify the model to make it work on their environment.