What to do when I change database engine

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
Zero-G.
Posts: 398
Joined: Sat 09 Dec 2006 12:20

What to do when I change database engine

Post by Zero-G. » Tue 12 Nov 2013 18:25

Hey
I use LinqConnect to mySql at the moment.
In future I want to use MsSql
So, I make a 1:1 portation from the DB. What do i have to change in my code?
Could you please give me a step by step introduce!

Thx

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: What to do when I change database engine

Post by MariiaI » Wed 13 Nov 2013 10:32

To change the database being used you should follow these steps:
1) Change the connection string in Entity Developer - in the Database Explorer, right-click Database Connection and select Edit Connection Properties from the shortcut menu.
2) After changing your connection from MySQL to SQL Server, your model still holds storage part and model mapping for the previous database - MySQL - and, because some data types in SQL Server and MySQL are different, the model is not valid.
Thus, please select "Regenerate Storage and Mapping" from the diagram shortcut menu for regenerating model parts, specific to the database server, or perform the "Update Database From Model" wizard with the "Regenerate Storage" check box selected if the database objects do not exist yet.
3) Make sure that the necessary Devart assemblies are available in your application:
- Devart.Data.dll;
- Devart.Data.Linq.dll;
- Devart.Data.SqlServer.Linq.dll.
4) Rebuild your application.

If you encounter any problems with this or have any further questions, feel free to contact us.

Zero-G.
Posts: 398
Joined: Sat 09 Dec 2006 12:20

Re: What to do when I change database engine

Post by Zero-G. » Fri 15 Nov 2013 15:03

Hey

I have a Problem - I can't find dotConnect for SQL Server in the DropDown List.
I have installed the Trial for the Moment of dotConnect for SQL

What am I doing wrong?
THX

Zero-G.
Posts: 398
Joined: Sat 09 Dec 2006 12:20

Re: What to do when I change database engine

Post by Zero-G. » Sat 16 Nov 2013 13:10

Ok, I found a Workaround, for everybody who would ever also need this.

1) You have to download Entity Developer Pro (or the right version for you)
If you have an other dotConnect product, it doesn't work, because it Looks
that These Versions are restricted to there product.
2) Open the lqml file with an Editor. There you find the following 2 lines (the
second and the third line int the file, they look like this:

Code: Select all

<Database Name="****" EntityNamespace="InvoiceContext" ContextNamespace="InvoiceContext" Class="InvoiceDataContext" xmlns:ed="http://devart.com/schemas/EntityDeveloper/1.0" ed:Guid="3a383a28-2522-4a23-91c8-e8aa63b110bf" [u]Provider="Devart.Data.MySql.Linq.Provider.MySqlDataProvider, Devart.Data.MySql.Linq" Extended="true" [/u]xmlns="http://schemas.devart.com/linqconnect/mapping">
  <Connection Mode[u]="ConnectionString" ConnectionString="User Id=*;Host=*;Port=*;Database=*;Persist Security Info=False" Provider="Devart.Data.MySql"[/u] />
  
This example Show you the MySQL Version
So, Change These two lines with the MSSql Version like this:

Code: Select all

<Database Name="*" EntityNamespace="InvoiceContext" ContextNamespace="InvoiceContext" Class="InvoiceDataContext" xmlns:ed="http://devart.com/schemas/EntityDeveloper/1.0" ed:Guid="3a383a28-2522-4a23-91c8-e8aa63b110bf" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">
  <Connection Mode="ConnectionString" ConnectionString="Data Source=*;Initial Catalog=*;Integrated Security=True;Persist Security Info=True" Provider="System.Data.SqlClient" />
The next Change you have to made is:
Let's say your database is called "DataBase" - So, you will find all tables build to:

Code: Select all

 DataBase.Table
But in MsSQL, all Table objects are called "dbo"
So Change "DataBase." to "dbo."
The database will be sent through the Catalog Statement!
3) Now you can open the lqml file with the Entity Developer (Don't use the Visual Studio plugged in one, I don't know why, but it Ends up, that the custom tool want open)
4) Once the file is opend in the Entity Developer you will see many Errors. - That's OK - Right click and open the Model settings. - Now you can choose from the
-Syncronisation -> Mapping the right MSSql Server Version.
5) Now you have to delete the Template on the left side of the overview. And add a new template (follow this short wizzard to find the right one for you)
6) SAFE THE FILE!!!!!
7) Regenerate the code.
That's it. - Now the complete code Generation has swapped from dotConnect to XXXX to MsSQL Version.

Happy coding...

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: What to do when I change database engine

Post by MariiaI » Mon 18 Nov 2013 10:49

dotConnect for SQL Server doesn't include LinqConnect support, Entity Developer, etc. To be able to create LinqConnect models for SQL Server, first of all it is necessary to have SQL Client Provider installed on your computer.
Please refer to:
http://www.devart.com/dotconnect/sqlser ... tions.html
http://www.devart.com/entitydeveloper/c ... ility.html (SQL Server)

To be able to work with LinqConnect models for both MySQL and SQL Server, you should install LinqConnect Standard or LinqConnect Professional additionally: http://www.devart.com/linqconnect/editions.html.
Entity Developer Professional doesn't include support for LinqConnect models, instead it supports LINQ to SQL models: http://www.devart.com/entitydeveloper/editions.html.

Thus, please use LinqConnect Standard or Professional and perform the steps described above again. In this case you do not need to change the LinqConnect model manually in the text editor.

Post Reply