Page 1 of 1

Multiple entities

Posted: Mon 12 Mar 2012 18:39
by imre.dudas
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

Posted: Mon 19 Mar 2012 10:44
by Shalex
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.

Posted: Mon 19 Mar 2012 13:39
by imre.dudas
Hello,

Thank you. I've chosen a second way.

Imre