Domain Approach - Change backend

6 posts, 1 answers
  1. Roland
    Roland avatar
    156 posts
    Member since:
    Feb 2009

    Posted 19 Nov 2010 Link to this post

    Hello,

    I am using the domain model approach in Q3 2010.
    I have configured domain model for SQL for now, but I will need the ability to change the backend in the config file to SQLite.

    The documentation refers only to the old style configuration. The GetBackendConfiguration method is static and hardcoded to SQL in my generated context class.

    public static BackendConfiguration GetBackendConfiguration()
    {
    BackendConfiguration backend = new BackendConfiguration();
    backend.Backend = "mssql";
    return backend;
    }


    How do I change the backend in the web.config file ?
  2. Answer
    Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 23 Nov 2010 Link to this post

    Hi Roland,

    I am afraid that this is not possible. The backend configuration is no longer kept in the app.config/web.config but in the .rlinq file instead. You can, however, use the following constructor of the OpenAccess context class to achieve similar result:
    MetadataSource metadataSource = XmlMetadataSource.FromAssemblyResource("EntityDiagrams1.rlinq");
    BackendConfiguration config = new BackendConfiguration();
    config.Backend = "sqlite";
     
    EntityDiagramsContext context = new EntityDiagramsContext ("YourConnectionString", config, metadataSource);

    If you really want to keep those settings in the configuration file, you can try to implement some custom logic that reads the needed settings from there and then use the code above. Hope that helps.

    Sincerely yours,
    Alexander
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
  3. DevCraft banner
  4. Roland
    Roland avatar
    156 posts
    Member since:
    Feb 2009

    Posted 23 Nov 2010 Link to this post

    Thanks, I figured that one out, but I thought it is still possible to use the openaccess config section.

  5. Erik
    Erik avatar
    314 posts
    Member since:
    Feb 2008

    Posted 14 Mar 2011 Link to this post

    Hi Alexander,

    Oops, I thought that was one of the nifty things, move from backend server...

    Also not from MySql to SQL Server?

    Thanks
  6. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 17 Mar 2011 Link to this post

    Hi Proovit,

    At the moment changing the backend is not recommended as one rlinq file can contain database specific information for only one backend. If you try to connect to another backend, for example mssql, while the rlinq is configured for mysql, this would most probably lead to runtime problems. However, if you use entirely forward mapping - start from an empty domain model and only add classes, without specifying any database-specific information, OpenAccess will use its default mapping and will be able to create a suitable database for any backend you would like to use. This way OpenAccess will handle the database specifics automatically, based on the currently selected backend and no errors should be observed.
    Support for multiple backend configurations in a single rlinq file is on our TODO list and will be implemented for one of the following releases later this year.

    Regards,
    Alexander
    the Telerik team
  7. Erik
    Erik avatar
    314 posts
    Member since:
    Feb 2008

    Posted 17 Mar 2011 Link to this post

    Ok, thanks for the info Alexander.
Back to Top
DevCraft banner