OpenAccess ORM - Multiple Database - Same Table Names - Error

4 posts, 0 answers
  1. Karthic Raghupathi
    Karthic Raghupathi avatar
    3 posts
    Member since:
    Oct 2009

    Posted 13 Nov 2009 Link to this post

    Greetings!

    I'm using OpenAccess ORM with Visual Studio 2008 for my projects. I have a situation where I need to connect to different databases and in a couple of databases, the table names are the same.

    Here is what I've done:

    ASP.NET C# Web Application - PostBackListener (which contains the DAL)

    Class Library - TechData(persistent classes - reverse mapped to DB)
    Class Library - Outbound (persistent classes - reverse mapped to DB)
    Class Library - CallOutbound (persistent classes - reverse mapped to DB)

    All the class libraries have been added as reference to the Web application and then the project is properly enabled for ORM access.

    In Outbound & CallOutbound, I have 2 tables Queue & Results in both Databases.

    Here are my config files

    *** edit - i had to remove my config files, code and error stack as it is apparently against my company policy folks! sorry about that! ***

    I have removed unwanted fields and other tables to keep it short. What matters is this  <extension key="db-table-name" value="Queue" />.

    *** edit - i had to remove my config files, code and error stack as it is apparently against my company policy folks! sorry about that! ***

    I have changed the Namespace and the name of the Persistent classes to be different. But they will map to tables having the same name in 2 different databases.

    Web.config - PostBackListener

    *** edit - i had to remove my config files, code and error stack as it is apparently against my company policy folks! sorry about that! ***

    So here is my code which throws an error:

    *** edit - i had to remove my config files, code and error stack as it is apparently against my company policy folks! sorry about that! ***

    And this is the error I get when the control hits the bold line in the above snippet.

    *** edit - i had to remove my config files, code and error stack as it is apparently against my company policy folks! sorry about that! ***

    I have also followed what was posted in response at this thread: ERROR during Multiple Persistent Class Reference. I still keep getting the same error.

    I have even specified separate Namespaces and separate class names for the tables.

    Any help in this regard would be greatly appreciated.
  2. Karthic Raghupathi
    Karthic Raghupathi avatar
    3 posts
    Member since:
    Oct 2009

    Posted 13 Nov 2009 Link to this post

    Hey guys!

    I was playing around for some more time figuring a way around this. When I stumbled to this page: Using Multiple Databases with OpenAccess ORM (MSSQL specific), I noticed an interesting way to configure the xml files which was.

    <class name="Person"
        <extension key="db-table-name" value="Database1.schema1.TabPers" /> 
    </class> 
    <class name="Address"
        <extension key="db-table-name" value="Database2.schema1.TabAddr" /> 
    </class> 

    So I went ahead and included the Database.schema before all the tables in my app.config files and it works like a charm now.

    Just out of curiosity, I think there is a better way to do this stuff. Am I missing some option in the wizard or is there some other thing I should do to automatically generate this stuff?

    Thanks for your time folks!
  3. DevCraft banner
  4. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 19 Nov 2009 Link to this post

    Hello Karthic Raghupathi,

    We are glad that you have solved your issue. It is true that in cases of using multiple databases that have tables with the same names, the full name of the table must be specified. That is doable only by hand at the moment but we could improve that for the future.

    Regards,
    Zoran
    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.
  5. Karthic Raghupathi
    Karthic Raghupathi avatar
    3 posts
    Member since:
    Oct 2009

    Posted 19 Nov 2009 Link to this post

    Thanks Zoran for your reply. It puts me at ease to know I did it right.

    And looking forward to see OpenAccess handle such hurdles in the future. Keep up the good work guys!
Back to Top