Discussion:
Entity framework - share same model with 3 different databases (M$Sql, MySql and Oracle)
(too old to reply)
Alberto Salvati
2017-08-18 08:00:48 UTC
Permalink
Hi, all.
I'm Alberto and I'ma delphi developersince 1997.
Now, I'm learning c# about c/s applications.


I need a win service application who process records in a specific database table to extract data needed to pupulate other tables.
Database could be Oracle, MySql or M$Sql (later I'll have Ibm db2...) with the same table structure with same field names.

Extraction and elaboration process is too complex, so I need classes to map in memory source and destinations records.
I know best ORM for .net is EF (note that I'm using JPA with java with other projects...).

So, I'm searching the right way to avoid code redundancy about connection with these different database types.

EF wizard asks about a specific db connection. I don't know:

1) if is possible customize autogenerated files to connect oracle and mysql insthead SqlServer and, id the answer is "yes", HOW do it

2) it's the right way or not? Maybe I need 3 different EF models with drawback about database structure changes?

I don't found useful informations on the web.


Thnaks in advance for any suggestion.

A.
Arne Vajhøj
2017-08-18 13:04:00 UTC
Permalink
Post by Alberto Salvati
I need a win service application who process records in a specific database table to extract data needed to pupulate other tables.
Database could be Oracle, MySql or M$Sql (later I'll have Ibm db2...) with the same table structure with same field names.
I suggest that you drop the M$ misspelling.
Post by Alberto Salvati
Extraction and elaboration process is too complex, so I need classes to map in memory source and destinations records.
I know best ORM for .net is EF (note that I'm using JPA with java with other projects...).
EF is is the most widely used ORM on .NET.

I don't think it is obvious that EF is better than NHibernate.
Post by Alberto Salvati
So, I'm searching the right way to avoid code redundancy about connection with these different database types.
1) if is possible customize autogenerated files to connect oracle and mysql insthead SqlServer and, id the answer is "yes", HOW do it
2) it's the right way or not? Maybe I need 3 different EF models with drawback about database structure changes?
I don't found useful informations on the web.
If you go for code first instead of database first, then switching
database should be a simple config change.

Example:

http://www.vajhoej.dk/arne/articles/dotnetdb.html#ef_code

Arne

Loading...