Suggest better way to implement dotConnect for various datasource

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
sathish.infotech
Posts: 3
Joined: Sun 19 May 2013 05:21

Suggest better way to implement dotConnect for various datasource

Post by sathish.infotech » Sun 19 May 2013 05:34

Hi,

Currently I am using dotConnect ORM for PostgreSQL datasource in my app.
Planning to map our app to point to SQLLite datasource for few customers.
So planning to get dotConnect ORM for SQLLite too.
So please suggest an better way to implement both the datasource in single app.
The app shud not know which datasource to be called. It has to be decided runtime only.
We already has class decorated with [ProviderAttribute(typeof(Devart.Data.PostgreSql.Linq.Provider.PgSqlDataProvider))] attribute.
So is there a better way so that we don't generate code with SQLLite ORM object, Instead use the existing class. But the above attribute type has to be decided at runtime.

Please Suggest

Thanks,
Sathish

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

Re: Suggest better way to implement dotConnect for various datasource

Post by MariiaI » Tue 21 May 2013 12:02

To use the same DataContext and entity classes for different databases, you should provide different mapping information for the context instances. For example, you can do this via the XML mapping.

In this case you should do the following:
1. Change "Mapping Mode" in model settings to "File". Entity Developer will generate the mapping file ([YourModelName].xml) for the database you are using.
2. Make a copy of the generated xml file.
3. Change the connection in the Database Explorer to the necessary one.
4. Check the Target Server in Model Settings -> Synchronization -> Mapping. It must be set to the one that you are going to use (i.e., to SQLite).
5. Run the Update Database Wizard to create the database objects; select the 'Regenerate Storage' option at the first step of the wizard.
6. Save changes and open the mapping file. Now it should contain mapping for the new database.
7. Save this new mapping file somewhere and repeat the previous steps for other databases, if necessary.

For more information about using XML mapping, see http://www.devart.com/linqconnect/docs/POCO.html

JIC: When working with different DBMSs it is necessary to clear the "Preserve schema name in storage" check box in the Model Settings.

Also, we recommend you to pay attention to the fluent mapping approach: http://www.devart.com/linqconnect/docs/ ... pping.html

Post Reply