Backend independent mapping

4 posts, 0 answers
  1. Anwar
    Anwar avatar
    14 posts
    Member since:
    Oct 2012

    Posted 29 Jul 2015 Link to this post

    Hi,

    I had a quick look at the following docs about backend independent mapping and I am just worried the whole process is a bit tedious:

    http://docs.telerik.com/data-access/developers-guide/code-only-mapping/mapping-clr-types-properties-and-associations/advanced-mapping/backend-independent-mapping/fluent-mapping-mapping-clr-advanced-backend-independent-change-backend

     

    What I did is to generate my db objects using an existing Firebird db (db first). The model is quite complex with many tables and some tables containing 100+ columns. I am now trying to switch to Oracle and reuse the original backend. As expected I am getting errors because data types differ between the 2 dbs. However the method described in the previous docs seem to be quite tedious where I need to specify one by one the problematic columns. Would it not be easier to simply regenerate the domain objects for both dbs?

     Am I missing something?

     

    Thanks!

    Anwar

     

     

  2. Yavor Slavchev
    Admin
    Yavor Slavchev avatar
    22 posts

    Posted 03 Aug 2015 Link to this post

    Hi Anwar,
    Thank you for contacting us.

    If you want to switch a fluent model to work with another backend, especially when this model is quite complex as in your scenario, you basically have two options:
    1. Modify your fluent model in order to support backend independent mapping if it is possible. The downside of this approach is that you manually have to go through the mapping and modify the columns but this is a one time effort anyway.
    2. The second option is to create another fluent model for the Oracle database, which mapping will fit the Oracle specific columns. The downside of this approach is that you have to maintain two mappings simultaneously and keep them in sync.

    If you plan to switch to Oracle and not use the Firebird db, I will recommend you to use the second approach to regenerate the mapping but if you plan to use the two data sources simultaneously, it is better to use the first approach and unify the column mappings.

    I hope this information is helpful.

    Regards,
    Yavor Slavchev
    Telerik
     
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
  3. DevCraft banner
  4. Anwar
    Anwar avatar
    14 posts
    Member since:
    Oct 2012

    Posted 05 Aug 2015 in reply to Yavor Slavchev Link to this post

    Hi Yavor,

     

    Thanks for the information. I will have to maintain 2 datasources (oracle & firebird), so I guess I will use the column mappings approach. However I am still not sure how to proceed after having read the documents.

     - In my case I am using a database first approach, i.e. the domain classes are generated from the db tables (including associations etc).

    - So basically I have a generated context inheriting from OpenAccesContext as well as an XmlMetadataSource which points to an .rling file.

     My question is: how do I adapt the generated artefacts so that my mappings are db independent (off course knowing that they have been generating using a specific db)?

     

    Thanks!

     

    Anwar

  5. Yavor Slavchev
    Admin
    Yavor Slavchev avatar
    22 posts

    Posted 07 Aug 2015 Link to this post

    Hello Anwar,

    Thank you for getting back to us.

    As it is explained in the documentation, in order to configure your properties in an abstract  manner, you have to change your fluent mapping by going through the entire mapping and changed the data source specific properties. There is no automated way to do this. This way, you will precisely review your mapping which will avoid further database specific problems.

    I hope this is helpful. Let us know if you have any further questions.

    Regards,
    Yavor Slavchev
    Telerik
     
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
Back to Top