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
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.
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.
Re: One Model with many DataBase
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
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
Re: One Model with many DataBase
Thanks. But...
Can you give as examples a small application.
Can you give as examples a small application.
Re: One Model with many DataBase
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.
Re: One Model with many DataBase
Thank you so much!
Best regards,
Karen Arzumanyan
Best regards,
Karen Arzumanyan
Re: One Model with many DataBase
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;
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.
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;
}
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.
Re: One Model with many DataBase
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
but should be like this
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.
Code: Select all
<Table Name="dbo.Users" Member="Users">
Code: Select all
<Table Name="Users" Member="Users">
- 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.
Re: One Model with many DataBase
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":
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":
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);
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();
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());
This sample show two error (all referenced DevExpress components included).
WindowsFormsApplication8.rar
PS: Use LinqConnect Professional Version 4.2.222 (04-Apr-2013);
Re: LinqConnect Professional Version 4.2.222 (04-Apr-2013) - One Model with many DataBase
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.
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.
Re: LinqConnect Professional Version 4.2.222 (04-Apr-2013) - One Model with many DataBase
OK. Tomorrow I will provide the details on the first problem.
Re: LinqConnect Professional Version 4.2.222 (04-Apr-2013) - One Model with many DataBase
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.
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.
Re: LinqConnect Professional Version 4.2.222 (04-Apr-2013) - One Model with many DataBase
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.
Re: LinqConnect Professional Version 4.2.222 (04-Apr-2013) - One Model with many DataBase
Thank you. For me this is very important.
Really looking forward the corrected version.
Really looking forward the corrected version.
Re: LinqConnect Professional Version 4.2.222 (04-Apr-2013) - One Model with many DataBase
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
For more information please refer to http://forums.devart.com/viewtopic.php?f=31&t=26911
Re: LinqConnect Professional Version 4.2.222 (04-Apr-2013) - One Model with many DataBase
Thanks!
I tested LinqConnect Professional Version 4.2.229 (18-Apr-2013), and all work without error.
I tested LinqConnect Professional Version 4.2.229 (18-Apr-2013), and all work without error.