OpenAccess section , .config, problem for 2 db and repository

Thread is closed for posting
4 posts, 1 answers
  1. Hans van Rijnswoud
    Hans van Rijnswoud avatar
    72 posts
    Member since:
    Sep 2008

    Posted 30 Nov 2009 Link to this post

    Hi,

    We deside to works now with telerik OpenAccess. We use the version : 2009.3.1119.2
    I read a couple of article about configuration, app.config, web.config, etc .... but i cannot found any information how to implement it correctly and my implementation don't work.

    I need to communicate with 2 differents database.
    I create so 2 projects class in VS2008, e.g.: with the name ORM1 and ORM2. I populate this projects with the Telerik OpenAccess Wizard.

    I create also a repository project too manage the standard method and I include a ObjectScopeProviderORM1 and ORM1Provider class to manage the scope and db connection. Also here i have again a app.config!

    Finally on my web project, i use the telerik wizard to enable this project to use OpenAccess.

    I have i total 3 app.config and 1 web.config

    My questions are:
    - Is it really necessary to have so many config? How to force the app.config to use the connection string of the web.config (if the telerik wizard don't find the connection string on the app.config he don't work anymore)
    -If I need to use all these config file, what is the best way?

    1/ here is the code that i use for ORM1:
    <configuration> 
      <configSections> 
        <section name="openaccess" type="Telerik.OpenAccess.Config.ConfigSectionHandler, Telerik.OpenAccess.Config, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342" requirePermission="false" /> 
      </configSections> 
      <openaccess xmlns="http://www.telerik.com/OpenAccess"
        <references /> 
        <backendconfigurations> 
          <backendconfiguration id="mssqlConfigurationProject1" backend="mssql"
            <mappingname>mssqlMapping</mappingname> 
          </backendconfiguration> 
        </backendconfigurations> 
        <mappings current="mssqlMapping"
          <mapping id="mssqlMapping"
            <namespace name="MegaAndCo.ORM"
    ..... 
    </mapping> 
        </mappings> 
        <connections> 
          <connection id="ProjectConnection"
            <connectionString>Data Source=Server;Initial Catalog=DBName;User ID=User;PasswordPassword=Password</connectionString> 
            <backendconfigurationname>mssqlConfigurationProject1</backendconfigurationname> 
          </connection> 
        </connections> 
      </openaccess> 
      <connectionStrings> 
        <add name="ProjectConnection" connectionString="data source=Server;initial catalog=DatabaseName;user id=UserName;password=Password" providerName="System.Data.SqlClient" /> 
      </connectionStrings> 
    </configuration> 




    2/ The app.config for ORM2 have the same structure of ORM1 but with other definition for connectionStrings, etc...

    3/ the app.config for my reposistory looks like this: (here i don't know who i can define a second mappgin, i found nothing about that).

    <configuration> 
      <configSections> 
        <section name="openaccess" type="Telerik.OpenAccess.Config.ConfigSectionHandler, Telerik.OpenAccess.Config, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342" requirePermission="false" /> 
      </configSections> 
      <openaccess xmlns="http://www.telerik.com/OpenAccess"
        <references> 
          <reference assemblyname="XXX.ORM1" configrequired="True" /> 
          <reference assemblyname="XXX.ORM2" configrequired="True" /> 
        </references> 
        <backendconfigurations> 
          <backendconfiguration id="mssqlConfigurationProject1" backend="mssql"
            <mappingname>mssqlMapping</mappingname> 
          </backendconfiguration> 
          <backendconfiguration id="mssqlConfigurationProject2" backend="mssql"
            <mappingname>mssqlMapping2</mappingname> 
          </backendconfiguration> 
        </backendconfigurations> 
        <mappings current="mssqlMapping"
          <mapping id="mssqlMapping"
            <namespace name="XXX.ORM1"
    ............... 
              </namespace> 
            </mapping> 
        </mappings> 
      </openaccess> 
    </configuration> 


    4/ finally my web.config:
    I use here the connection strings (or do I need also to define the tag <openaccess> ??)
      <connectionStrings> 
        <clear /> 
        <add name="ORM1" connectionString="data source=Server;database=DBNAME;user id=USER;password=PWD;application name=ORMCMS" providerName="System.Data.SqlClient" /> 
        <add name="ORM2" connectionString="data source=Server;database=DBNAME;user id=USERNAME;password=PWD;application name=ORMCORE" providerName="System.Data.SqlClient" /> 
      </connectionStrings> 



    I hoop there is a easy way to implement this??

    Thanks in advance for your advice.

    Edwin.
  2. Hans van Rijnswoud
    Hans van Rijnswoud avatar
    72 posts
    Member since:
    Sep 2008

    Posted 01 Dec 2009 Link to this post

    We move to Linq, more easy to implement.
    Also it would be great if you can add in OpenAccess menu inside VisulaStudio the menu : disabled Project to use ORM...

    Regards,

    Edwin
  3. Answer
    Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 03 Dec 2009 Link to this post

    Hi Edwin Blom,

    Yes you need an App.config file per project which is enabled to use the Telerik OpenAccess ORM. In order to use settings which are located in different configuration file you should add reference to this assembly as well as the following entry inside the current configuration file:

    <references>
      <reference assemblyname="Assembly_Name" configrequired="True" />
    </references>

    If the Web application / website is enabled to use the Telerik OpenAccess ORM the openaccess tag is necessary.
    I hope the provided information will be helpful. If any other questions arise please contact us.

    Kind regards,
    Damyan Bogoev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  4. Hans van Rijnswoud
    Hans van Rijnswoud avatar
    72 posts
    Member since:
    Sep 2008

    Posted 08 Dec 2009 Link to this post

    Hi Damyan Bogoev,

    Thank you for this information.
    I cannot test your solution because we have implemented Linq via SqlMetal and it's work for us perfectly.
    I keep well this information for an eventually future project with OpenAccess.

    Have a nice day,

    Regards,

    Edwin.
Back to Top