Telerik OpenAccess Classic

Telerik OpenAccess ORM Send comments on this topic.
How to: Manage database connection settings of web sites and web applications during deployment
Programmer's Guide > OpenAccess ORM Classic (Old API) > OpenAccess Tasks > Connections and Data Store Management > How to: Manage database connection settings of web sites and web applications during deployment

Glossary Item Box

This documentation article is a legacy resource describing the functionality of the deprecated OpenAccess Classic only. The contemporary documentation of Telerik OpenAccess ORM is available here.

This article discusses a topic regarding deployment of a web site project, which accesses a database using Telerik OpenAccess ORM.

We are considering a scenario involving a web site that is being developed using the standard procedures for enabling a web site to use Telerik OpenAcess ORM.

By default, all the database connection details are part of the app.config file that belongs to the class library where the persistent classes are placed. Having in mind that the class library is deployed as a compiled assembly and it contains the app.config as an embedded resource,  we are  unable to change the database connection details after deployment on a server machine.  To be able to do that, we have to let OpenAccess read the connection from the web.config file, which is explained in more details in the section below.

Moving the connection settings to the Web.config file

To be able to change the database connection settings from web.config after deployment, you need to follow these steps:

  1. Open the “App.config” file from your Class library project that contains the model
  2. Locate the <connections> section

    ...

    App.config Copy Code
    <openaccess xmlns="http://www.telerik.com/OpenAccess">
       <references />
       
    <connections>
         
    <connection id="DatabaseConnection2">
           
    <databasename>Northwind</databasename>
           
    <servername>(LOCAL)\SQLEXPRESS</servername>
           
    <integratedSecurity>True</integratedSecurity>
           
    <backendconfigurationname>mssqlConfiguration</backendconfigurationname>
         
    </connection>
       
    </connections>
       
    <backendconfigurations>

    ...

  3. Cut the whole section
  4. Locate the “<openaccess>” tag in your “Web.config” file
    Web.config Copy Code
    <openaccess xmlns="http://www.telerik.com/OpenAccess">
    <references>
     
    <reference assemblyname="ClassLibrary" configrequired="True"/>
    </references>
    <connections/>
    </
    openaccess>
    If the <openAccess> section is not available in your Web.config file, run the Enable Project To Use ORM wizard on your web site project.
  5. Replace the “<connections />” section with the section from the “App.config” file
    After this step, your <openaccess> section should have the following form in the web.config file:
    Web.config Copy Code
    <openaccess xmlns="http://www.telerik.com/OpenAccess">
    <references>
     
    <reference assemblyname="ClassLibrary" configrequired="True"/>
    </references>
     
    <connections>
     
    <connection id="DatabaseConnection2">
    <databasename>Northwind</databasename>
    <servername>(LOCAL)\SQLEXPRESS</servername>
    <integratedSecurity>True</integratedSecurity>
    <backendconfigurationname>mssqlConfiguration</backendconfigurationname>
     
    </connection>
    </
    connections>
    </
    openaccess>

     

  6. Select the Class library project containing the “App.config” file from the Solution explorer
  7. In the properties window remove the value of the “ConnectionID” property

At this point, a web application is ready for deployment as an administrator is able to change the database connection settings from the “Web.config” file  and adjust it for usage on any server machine.