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

[Solved] Does OpenAccess ORM support distributed database?

2 Answers 130 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tajes
Top achievements
Rank 1
Tajes asked on 18 Nov 2010, 10:38 AM
Hi,
   My question is if we have some databases with the same schema but different data, can we use OpenAccess to manage them like only one database?
  If we cannot do that, can we create several instances of the same context object, one for each database?
  Our problem is that we will have many identical Databases with same schema, but we don't know How many, and we need to create and manage differents conections but using the same DAL and persistent clases.

   Is this possible?

Thanks in advance.

2 Answers, 1 is accepted

Sort by
0
Accepted
Petko_I
Telerik team
answered on 22 Nov 2010, 05:50 PM
Hello Iván Tajes,

It is possible to use one and the same model to connect to different databases as long as the database schemata are identical and you use the same backend (for example mssql). Since the databases differ only in their data the mapped conceptual model will be the same and OpenAccess will be able to handle the different connections correctly. Let me give you an example - we will use two different connection strings to connect to Northwind and NorthwindOA databases.
<connectionStrings>
    <add name="NorthwindEntityDiagrams" connectionString="data source=.\SQLEXPRESS;initial catalog=Northwind;integrated security=True" providerName="System.Data.SqlClient" />
    <add name="NorthwindOAEntityDiagrams" connectionString="data source=.\SQLEXPRESS;initial catalog=NorthwindOA;integrated security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>
Now, we can take advantage of the OpenAccessContext constructor which accepts a connection id as an argument.
string connection = "NorthwindOAEntityDiagrams";
using (NorthwindEntityDiagrams context = new NorthwindEntityDiagrams(connection))
{
    var employees = context.Employees.ToList();
}
 
connection = "NorthwindEntityDiagrams";
using (NorthwindEntityDiagrams context = new NorthwindEntityDiagrams(connection))
{
    var employees = context.Employees.ToList();
}
What cannot be achieved automatically by OpenAccess is to manage the CRUD operations on all databases simultaneously, i.e. with one context you can work with one corresponding database and any changes you make to that database will need to be synchronized with the other databases through code.

I hope this answers your questions. Do not hesitate to contact us again if you want to continue the discussion.

Sincerely yours,
Petko_I
the Telerik team
Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
0
Tajes
Top achievements
Rank 1
answered on 23 Nov 2010, 09:21 AM
Thank you so much Petko_I. This is very helpfull.
Greetings
Tags
General Discussions
Asked by
Tajes
Top achievements
Rank 1
Answers by
Petko_I
Telerik team
Tajes
Top achievements
Rank 1
Share this question
or