Multiple entities

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
imre.dudas
Posts: 18
Joined: Thu 11 Mar 2010 20:36

Multiple entities

Post by imre.dudas » Mon 12 Mar 2012 18:39

Hi to all,

I am making a software that is able to handle local and remote databases. The local one is an SQLite , the remote is an PostgreSQL database. The handling of databases is implemented into a DLL.

As far as the structure, these two databases are the same: same tables, tables have the same columns.

My initial imagination was that I would make two models with Entity Developer. One modell would handle the first, the other would handle the second database. I got into the fault that since table names are the same, these two modells cannot fit into the same project, because duplications occure due to same names.

It is not hard to rename classes with a prefix in the following way: lTable1, lTablle2, … rTable1, rTable2, or use different namespaces, but I would avoid this method if possible.

Is there any regular solution for this?

Thanks:
Imre

Shalex
Site Admin
Posts: 8248
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Mon 19 Mar 2012 10:44

There are two ways:
1. XML mapping. As a possible solution, you can define your, for example, PostgreSQL model as a "primary" model that is used for code generation. The second (for SQLite) model will contain only SSDL part. Please refer to our EFQuerySamples ( http://www.devart.com/dotconnect/oracle ... amples.zip ) to get an example how to work with several SSDL parts for different databases.
2. Fluent mapping. For more information on how to use fluent mapping (code first) in our EF-providers, see Entity Framework Code-First support for Oracle, MySQL, PostgreSQL and SQLite. You can also download a sample for serveral databases there.

imre.dudas
Posts: 18
Joined: Thu 11 Mar 2010 20:36

Post by imre.dudas » Mon 19 Mar 2012 13:39

Hello,

Thank you. I've chosen a second way.

Imre

Post Reply