LinqConnect Professional Version 4.2.222 (04-Apr-2013) - One Model with many DataBase

LinqConnect Professional Version 4.2.222 (04-Apr-2013) - One Model with many DataBase

Postby AKRRKA » Fri 27 Jul 2012 16:30

The problem is as follows:
Need to make an application that will transparently work with multiple databases (eg MySQL, Oracle, SQLite). I bought already and try to use this "LinqConnect Professional 4.x".

The question is:
How to do it. It is desirable that had one "DataContext", ie in the project one ORM model and could be through it gain access to any of the databases to which the user wishes to connect.

There is an example of such a realization and is it possible at all?
Very much I ask greetings to this example.
Last edited by AKRRKA on Fri 05 Apr 2013 17:19, edited 1 time in total.
AKRRKA
 
Posts: 194
Joined: Thu 26 Jan 2012 15:07
Location: Russia

Re: One Model with many DataBase

Postby MariiaI » Mon 30 Jul 2012 09:23

To use the same DataContext and entity classes for different databases, you should provide different mapping information for the context instances. For example, you can do this via the XML mapping.

In this case you should do the following:
1. Change "Mapping Mode" in model settings to "File". Entity Developer will generate the mapping file ([YourModelName].xml) for the database you are using.
2. Make a copy of the generated xml file.
3. Change connection in the Database Explorer to the necessary one.
4. Check the Target Server in Model Settings -> Synchronization -> Mapping. It must be set to the one that you are going to use (i.e., to MySQL Server of the proper version).
5. Run the Update Database Wizard to create the database objects; select the 'Regenerate Storage' option at the first step of the wizard.
6. Save changes and open the mapping file. Now it should contain mapping for the new database.
7. Save this new mapping file somewhere and repeat the previous steps for other databases, if necessary.

For more information about using XML mapping, see http://www.devart.com/linqconnect/docs/POCO.html
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: One Model with many DataBase

Postby AKRRKA » Thu 02 Aug 2012 10:27

Thanks. But...
Can you give as examples a small application.
AKRRKA
 
Posts: 194
Joined: Thu 26 Jan 2012 15:07
Location: Russia

Re: One Model with many DataBase

Postby MariiaI » Thu 02 Aug 2012 12:40

We have sent you a sample project, that demonstrates how to work with multiple databases using one DataContext. Please check that the letter is not blocked by your mail filter.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: One Model with many DataBase

Postby AKRRKA » Fri 03 Aug 2012 06:35

Thank you so much!

Best regards,
Karen Arzumanyan
AKRRKA
 
Posts: 194
Joined: Thu 26 Jan 2012 15:07
Location: Russia

Re: One Model with many DataBase

Postby AKRRKA » Thu 04 Apr 2013 08:12

Hello.

I have new big problem.

I create my application like in you sample.
All OK, but if I need change DB type without close/open application, i get a problem.
You can see this error in my example.

1) Connect to MySQL (automated get data and show in grid);
2) Disconnect Context connection and dispose contest, and context variable assign null;
Code: Select all
        private void sbCloseConnection_Click(object sender, EventArgs e)
        {
            DataContext.Connection.Close();
            DataContext.Dispose();
            DataContext = null;
        }

3) Connect to SQL Server. And get Error!
The connection is open correctly. But if I try get data have the error -2146233088

If first connect to SQLServer, and after to MySQL, also get tis error.

What am I doing wrong?How to correctly remove and reset the variable context to use it for other databases?

Sample application: http://rghost.ru/45031534

PS: It is very important to me. Please help a high-priority issue.
PPS: Use LinqConnect Professional Version 4.1.197 (28-Feb-2013).

Thanks.
AKRRKA
 
Posts: 194
Joined: Thu 26 Jan 2012 15:07
Location: Russia

Re: One Model with many DataBase

Postby MariiaI » Fri 05 Apr 2013 07:44

When working with different DBMSs it is necessary to clear the "Preserve schema name in storage" check box in the Model Settings. The error, you are getting, occurs because your generated xml files contain the information, like this
Code: Select all
<Table Name="dbo.Users" Member="Users">

but should be like this
Code: Select all
<Table Name="Users" Member="Users">

Thus, please do the following:
- clear the "Preserve schema name in storage" check box in the Model Settings;
- re-create your model in order to changes become effective for all Entity classes; use the "Update Model from Database" wizard with the selected "Recreate Model" option;
- re-generate xml mapping files for the necessary databases.

Please tell us if this helps.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: One Model with many DataBase

Postby AKRRKA » Fri 05 Apr 2013 17:15

Yes, for DataGridView, this solution worked.

But in fact I used in the project DevExpress.XtraGrid. And with it the solution did not work.
Also i have a problem without any grid, just select data after change database.

First problem:
1) Connect MySQL;
2) Press - "Get Xtra";
3) Connect SQL Server;
4) Press - "Get Xtra" - Have a Error;
If first connect to SQLServer, and after to MySQL, also get tis error on step 4.
Code for "Get Xtra":
Code: Select all
var rllist = from us in DataContext.Users select us;

var iCount = rllist.Count();
MessageBox.Show(@"Get Count : " + iCount.ToString());

gridControlData.DataSource = null;
gridControlData.DataMember = null;
gridControlData.DataBindings.Clear();

MessageBox.Show(@"Select Data - for DevExpress.XtraGrid");
gridControlData.DataSource = rllist;
gridControlData.RefreshDataSource();


Second problem:
1) Connect MySQL;
2) Press - "Get Error";
3) Connect SQL Server;
4) Press - "Get Error";
If first connect to SQLServer, and after to MySQL, also get tis error on step 4.
Code for "Get Error":
Code: Select all
var isNotEmpty = DataContext.Users.Any(ug => ug.Name != "");
MessageBox.Show(@"isNotEmpty : " + isNotEmpty.ToString());


Please help me.

This sample show two error (all referenced DevExpress components included).
WindowsFormsApplication8.rar

PS: Use LinqConnect Professional Version 4.2.222 (04-Apr-2013);
AKRRKA
 
Posts: 194
Joined: Thu 26 Jan 2012 15:07
Location: Russia

Re: LinqConnect Professional Version 4.2.222 (04-Apr-2013) - One Model with many DataBase

Postby MariiaI » Mon 08 Apr 2013 13:04

Thank you for the test sample.
We couldn't reproduce the first issue with your sample (with the DevExpress gridview). Please specify the full text of the exception and its stack trace.
As for the second issue, we have reproduced it. We will investigate it and inform you about the results as soon as possible.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: LinqConnect Professional Version 4.2.222 (04-Apr-2013) - One Model with many DataBase

Postby AKRRKA » Mon 08 Apr 2013 16:12

OK. Tomorrow I will provide the details on the first problem.
AKRRKA
 
Posts: 194
Joined: Thu 26 Jan 2012 15:07
Location: Russia

Re: LinqConnect Professional Version 4.2.222 (04-Apr-2013) - One Model with many DataBase

Postby AKRRKA » Tue 09 Apr 2013 09:25

Video with demonstration first problem: Link
Get different error text for the cases when first connecting to MySQL and if the first server to the SQL Server. You can look at the video.

I think that both problems are related. But I can not understand how. Cause I reset (dispose and assign to null) context variables. But still is stored somewhere previous provider.
AKRRKA
 
Posts: 194
Joined: Thu 26 Jan 2012 15:07
Location: Russia

Re: LinqConnect Professional Version 4.2.222 (04-Apr-2013) - One Model with many DataBase

Postby MariiaI » Wed 10 Apr 2013 10:05

Thank you for the additional information. Apparently, these issues are related to the query cache. We have made some changes which should fix them. We will inform you when the new build with the fix is available for download.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: LinqConnect Professional Version 4.2.222 (04-Apr-2013) - One Model with many DataBase

Postby AKRRKA » Wed 10 Apr 2013 11:47

Thank you. For me this is very important.
Really looking forward the corrected version.
AKRRKA
 
Posts: 194
Joined: Thu 26 Jan 2012 15:07
Location: Russia

Re: LinqConnect Professional Version 4.2.222 (04-Apr-2013) - One Model with many DataBase

Postby MariiaI » Fri 19 Apr 2013 06:44

The new build of LinqConnect 4.2.229 is available for download now. It can be downloaded from http://www.devart.com/linqconnect/download.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information please refer to http://forums.devart.com/viewtopic.php?f=31&t=26911
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: LinqConnect Professional Version 4.2.222 (04-Apr-2013) - One Model with many DataBase

Postby AKRRKA » Fri 19 Apr 2013 10:12

Thanks!
I tested LinqConnect Professional Version 4.2.229 (18-Apr-2013), and all work without error.
AKRRKA
 
Posts: 194
Joined: Thu 26 Jan 2012 15:07
Location: Russia

Next

Return to LinqConnect (LINQ to SQL support)