This is a migrated thread and some comments may be shown as answers.

OpenAccess ORM - Multiple Database - Same Table Names - Error

3 Answers 66 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Karthic Raghupathi
Top achievements
Rank 1
Karthic Raghupathi asked on 13 Nov 2009, 05:27 PM
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.

3 Answers, 1 is accepted

Sort by
0
Karthic Raghupathi
Top achievements
Rank 1
answered on 13 Nov 2009, 07:27 PM
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!
0
Zoran
Telerik team
answered on 19 Nov 2009, 10:28 AM
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.
0
Karthic Raghupathi
Top achievements
Rank 1
answered on 19 Nov 2009, 03:09 PM
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!
Tags
Development (API, general questions)
Asked by
Karthic Raghupathi
Top achievements
Rank 1
Answers by
Karthic Raghupathi
Top achievements
Rank 1
Zoran
Telerik team
Share this question
or