Click here to Skip to main content
13,254,366 members (67,137 online)
Rate this:
Please Sign up or sign in to vote.
I am using and currently working with SQL SERVER 2008.
In my code all the DML operation is happening with the help of
SqlConnection, SqlCommand, SqlDataAdapter.

But when If my database move to ORACLE or MySQL then I would need to write the code for
ORACLE -- OLEDBConnection, OLEDBCommand, OLEDBDataAdapter
MySQL -- Would need to include a MySQL dll.

Now due to this huge change I would need to write the entire code again.

Is there any way to overcome this problem that we write the code at once and that would not depend on the database provider?
Does the Entity Framework come in this picture anywhere?

Please guide me.

Posted 29-Dec-12 3:24am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Actually you can use OleDb for most of the databases. You just have to make sure that you have proper OleDb provider downloaded. For example Oracle OleDb provider can be loaded from Oracle site, for MySql you can use OleDb for ODBC and MySql ODBC driver if no suitable OleDb provider is found for that (the only ones I know are commercial) and so forth.

However there are few things you must remember:
- when working with OleDb with multiple databases you cannot use database specific features for .Net objects (ones that exist for example for SqlCOnnection or OracleConnection)
- The SQL syntax is still different. For each database you may have to create alternative versions for all statements.

You could of course create small wrapper classes to hide the actual connection, command etc objects but still you have differences in SQL syntax between the databases.

EF can be used to make your code more compatible with all the databases. However there still may be situations where you have to write SQL and/or the behaviour is different between databases.
Espen Harlinn 30-Dec-12 8:13am
Nice reply :-D
Mika Wendelius 4-Jan-13 15:12pm
Thanks Espen :-D
Manish Kumar Namdev 7-Jan-13 0:15am
Thanks Mika Wendelius for reply...
Please guide me a bit more in the context of E.F.
Are both the Entity Framework and Ado .net Entity Frame same or different?
There are four approaches 1. Database First 2. Model First 3. Code First 4. Code First with Existing database.

The working style with E.F. and LINQ TO SQL is smilimar.

Please correct me if I'm at wrong somewhere.

Mika Wendelius 10-Jan-13 2:31am
Entity framework is ADO.Net based so it's the same thing. The approach to be used is based on your way to work, do you first create the database and then the code etc.

The working style is quite similar. However, EF has lots of more capabilities for example regarding to navigation using foreign keys etc.

So basically yes, you're quite correct :)
Manish Kumar Namdev 11-Jan-13 1:36am
Thanks Mika.

Mika Wendelius 11-Jan-13 1:38am
You're welcome :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.171114.1 | Last Updated 29 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100